Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Application/Changeable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import type { Application } from "./index"

export interface Changeable {
name?: Application["name"]
selfSignOn?: boolean
permissions?: Application["permissions"]
}
export namespace Changeable {
export const type = isly.object<Changeable>({
name: isly.string(/.+/).optional(),
selfSignOn: isly.boolean().optional(),
permissions: isly.array(isly.string(/.+/)).optional(),
})
export const is = type.is
Expand Down
2 changes: 2 additions & 0 deletions Application/Creatable.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { isly } from "isly"
export interface Creatable {
name: string
selfSignOn?: boolean
permissions?: string[]
}
export namespace Creatable {
export const type = isly.object<Creatable>({
name: isly.string(/.+/),
selfSignOn: isly.boolean().optional(),
permissions: isly.array(isly.string(/.+/)).optional(),
})
export const is = type.is
Expand Down
14 changes: 5 additions & 9 deletions Application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ export interface Application extends Omit<Application.Creatable, "permissions">
}

export namespace Application {
export type Identifier = ApplicationIdentifier
export const Identifier = ApplicationIdentifier
export type Creatable = ApplicationCreatable
export const Creatable = ApplicationCreatable
export const Changeable = ApplicationChangeable
export type Changeable = ApplicationChangeable
export const type = isly.object<Application>({
export import Identifier = ApplicationIdentifier
export import Creatable = ApplicationCreatable
export import Changeable = ApplicationChangeable
export const type = Creatable.type.omit(["permissions"]).extend<Application>({
id: Identifier.type,
name: isly.string(),
organizations: isly.record(Organization.Identifier.type, Organization.type),
permissions: isly.array(isly.string()),
organizations: isly.record(Organization.Identifier.type, Organization.type),
created: isly.fromIs("isoly.DateTime", isoly.DateTime.is),
modified: isly.fromIs("isoly.DateTime", isoly.DateTime.is),
})
Expand Down
6 changes: 5 additions & 1 deletion ClientCollection/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export class Organization extends rest.Collection<gracely.Error> {
)
if (userwidgetsOrganization.is(result))
this.entityTags.organization[result.id] = isoly.DateTime.now()
return result
return userwidgetsOrganization.is(result) ||
!("organization" in result) ||
!userwidgetsOrganization.is(result.organization)
? result
: result.organization
}
async fetch(id: userwidgets.Organization.Identifier): Promise<userwidgets.Organization | gracely.Error> {
const result = await this.client.get<userwidgets.Organization>(
Expand Down
3 changes: 3 additions & 0 deletions Organization/Creatable.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { isly } from "isly"
import { Email } from "../Email"
import { Identifier } from "./Identifier"
export interface Creatable {
id?: Identifier
name: string
permissions?: string[]
user?: Email
}

export namespace Creatable {
export const type = isly.object<Creatable>({
id: Identifier.type.optional(),
name: isly.string(/.+/),
permissions: isly.array(isly.string(/.+/)).optional(),
user: Email.type.optional(),
})
export const is = type.is
export const flaw = type.flaw
Expand Down
23 changes: 8 additions & 15 deletions Organization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,24 @@ import { Changeable as OrganizationChangeable } from "./Changeable"
import { Creatable as OrganizationCreatable } from "./Creatable"
import { Identifier as OrganizationIdentifier } from "./Identifier"

export interface Organization extends Omit<Organization.Creatable, "permissions"> {
export interface Organization extends Omit<Organization.Creatable, "permissions" | "user"> {
id: Organization.Identifier
created: isoly.DateTime
modified: isoly.DateTime
users: Email[]
permissions: string[]
created: isoly.DateTime
modified: isoly.DateTime
}

export namespace Organization {
export type Identifier = OrganizationIdentifier
export const Identifier = OrganizationIdentifier
export type Creatable = OrganizationCreatable
export const Creatable = OrganizationCreatable
export type Changeable = OrganizationChangeable
export const Changeable = OrganizationChangeable
export namespace Changeable {
export type Invite = OrganizationChangeable.Invite
}
export const type = isly.object<Organization>({
export import Identifier = OrganizationIdentifier
export import Creatable = OrganizationCreatable
export import Changeable = OrganizationChangeable
export const type = Creatable.type.omit(["permissions", "id", "user"]).extend<Organization>({
id: Identifier.type,
name: isly.string(/.+/),
users: isly.array(Email.type),
permissions: isly.array(isly.string(/.+/)),
created: isly.fromIs("isoly.DateTime", isoly.DateTime.is),
modified: isly.fromIs("isoly.DateTime", isoly.DateTime.is),
users: isly.array(Email.type),
})
export const is = type.is
export const flaw = type.flaw
Expand Down
37 changes: 14 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"prettierx": "github:utily/prettierx#utily-20231004",
"rimraf": "^6.0.1",
"ts-jest": "^29.2.5",
"typescript": "^5.4.5"
"typescript": "5.5.4"
},
"dependencies": {
"authly": "^3.1.2",
Expand Down