From c19ecbd98587b4de294b0826f4cb6bfe40600dce Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Wed, 20 Nov 2024 10:59:54 +0100 Subject: [PATCH 01/10] initial --- Application/Changeable.ts | 2 ++ Application/Creatable.ts | 2 ++ Application/index.ts | 6 +++--- Organization/Creatable.ts | 3 +++ Organization/index.ts | 4 +++- package-lock.json | 36 +++++++++++++----------------------- package.json | 2 +- 7 files changed, 27 insertions(+), 28 deletions(-) diff --git a/Application/Changeable.ts b/Application/Changeable.ts index 6d9c17c..2148093 100644 --- a/Application/Changeable.ts +++ b/Application/Changeable.ts @@ -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({ name: isly.string(/.+/).optional(), + selfSignOn: isly.boolean().optional(), permissions: isly.array(isly.string(/.+/)).optional(), }) export const is = type.is diff --git a/Application/Creatable.ts b/Application/Creatable.ts index bbd4921..032dfeb 100644 --- a/Application/Creatable.ts +++ b/Application/Creatable.ts @@ -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({ name: isly.string(/.+/), + selfSignOn: isly.boolean(), permissions: isly.array(isly.string(/.+/)).optional(), }) export const is = type.is diff --git a/Application/index.ts b/Application/index.ts index 1ef9b97..82cd293 100644 --- a/Application/index.ts +++ b/Application/index.ts @@ -19,11 +19,11 @@ export namespace Application { export const Creatable = ApplicationCreatable export const Changeable = ApplicationChangeable export type Changeable = ApplicationChangeable - export const type = isly.object({ + export const type = Creatable.type.omit(["permissions", "selfSignOn"]).extend({ 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), + selfSignOn: isly.boolean(), created: isly.fromIs("isoly.DateTime", isoly.DateTime.is), modified: isly.fromIs("isoly.DateTime", isoly.DateTime.is), }) diff --git a/Organization/Creatable.ts b/Organization/Creatable.ts index 4fc5ad6..e83de47 100644 --- a/Organization/Creatable.ts +++ b/Organization/Creatable.ts @@ -1,9 +1,11 @@ import { isly } from "isly" +import { Creatable as User } from "../User/Creatable" import { Identifier } from "./Identifier" export interface Creatable { id?: Identifier name: string permissions?: string[] + user?: User } export namespace Creatable { @@ -11,6 +13,7 @@ export namespace Creatable { id: Identifier.type.optional(), name: isly.string(/.+/), permissions: isly.array(isly.string(/.+/)).optional(), + user: User.type.optional(), }) export const is = type.is export const flaw = type.flaw diff --git a/Organization/index.ts b/Organization/index.ts index 79e6029..e45f518 100644 --- a/Organization/index.ts +++ b/Organization/index.ts @@ -23,14 +23,16 @@ export namespace Organization { export namespace Changeable { export type Invite = OrganizationChangeable.Invite } - export const type = isly.object({ + export const type = Creatable.type.omit(["permissions", "user"]).extend({ id: Identifier.type, name: isly.string(/.+/), 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), + // user: }) + // export const type = isly.object({}) export const is = type.is export const flaw = type.flaw } diff --git a/package-lock.json b/package-lock.json index 23eb13e..04529af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "prettierx": "github:utily/prettierx#utily-20231004", "rimraf": "^6.0.1", "ts-jest": "^29.2.5", - "typescript": "^5.4.5" + "typescript": "5.5.4" } }, "node_modules/@ampproject/remapping": { @@ -664,7 +664,8 @@ "node_modules/@cloudflare/workers-types": { "version": "4.20241112.0", "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20241112.0.tgz", - "integrity": "sha512-Q4p9bAWZrX14bSCKY9to19xl0KMU7nsO5sJ2cTVspHoypsjPUMeQCsjHjmsO2C4Myo8/LPeDvmqFmkyNAPPYZw==" + "integrity": "sha512-Q4p9bAWZrX14bSCKY9to19xl0KMU7nsO5sJ2cTVspHoypsjPUMeQCsjHjmsO2C4Myo8/LPeDvmqFmkyNAPPYZw==", + "license": "MIT OR Apache-2.0" }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", @@ -1950,6 +1951,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/authly/-/authly-3.1.2.tgz", "integrity": "sha512-hUOOHhU+t5MFtP3RQdgcUDH3ShCaVCpm5la2Z2anBmgrTnrJsP0NxMGj5g8c2xSpvQM6WwOrYz0IYbf4p6s08A==", + "license": "MIT", "dependencies": { "cryptly": "4.0.6" }, @@ -2459,9 +2461,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", - "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -3222,20 +3224,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -3739,7 +3727,8 @@ "node_modules/isoly": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/isoly/-/isoly-2.3.11.tgz", - "integrity": "sha512-81pWrkWsGUnUbEZ4YknE67m+4LMrohVlXaqK7tvrO8n0/85bgxCwqAWzbMnlc8O+xd3joxzjXxjvoO2XRY3cNw==" + "integrity": "sha512-81pWrkWsGUnUbEZ4YknE67m+4LMrohVlXaqK7tvrO8n0/85bgxCwqAWzbMnlc8O+xd3joxzjXxjvoO2XRY3cNw==", + "license": "MIT" }, "node_modules/istanbul-lib-coverage": { "version": "3.2.2", @@ -6383,10 +6372,11 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 308e49b..516352f 100644 --- a/package.json +++ b/package.json @@ -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", From 2ad97866bbff5e3d3953e4f4b4d38da5a7975b26 Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Wed, 20 Nov 2024 11:03:05 +0100 Subject: [PATCH 02/10] optional self sign on --- Application/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Application/index.ts b/Application/index.ts index 82cd293..c3ca24f 100644 --- a/Application/index.ts +++ b/Application/index.ts @@ -19,11 +19,10 @@ export namespace Application { export const Creatable = ApplicationCreatable export const Changeable = ApplicationChangeable export type Changeable = ApplicationChangeable - export const type = Creatable.type.omit(["permissions", "selfSignOn"]).extend({ + export const type = Creatable.type.omit(["permissions"]).extend({ id: Identifier.type, permissions: isly.array(isly.string()), organizations: isly.record(Organization.Identifier.type, Organization.type), - selfSignOn: isly.boolean(), created: isly.fromIs("isoly.DateTime", isoly.DateTime.is), modified: isly.fromIs("isoly.DateTime", isoly.DateTime.is), }) From edeb62aee14505ec5347032ed9e06ebf9bb4464e Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Wed, 20 Nov 2024 11:22:11 +0100 Subject: [PATCH 03/10] no org change --- Organization/Creatable.ts | 3 --- Organization/index.ts | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Organization/Creatable.ts b/Organization/Creatable.ts index e83de47..4fc5ad6 100644 --- a/Organization/Creatable.ts +++ b/Organization/Creatable.ts @@ -1,11 +1,9 @@ import { isly } from "isly" -import { Creatable as User } from "../User/Creatable" import { Identifier } from "./Identifier" export interface Creatable { id?: Identifier name: string permissions?: string[] - user?: User } export namespace Creatable { @@ -13,7 +11,6 @@ export namespace Creatable { id: Identifier.type.optional(), name: isly.string(/.+/), permissions: isly.array(isly.string(/.+/)).optional(), - user: User.type.optional(), }) export const is = type.is export const flaw = type.flaw diff --git a/Organization/index.ts b/Organization/index.ts index e45f518..237e9b7 100644 --- a/Organization/index.ts +++ b/Organization/index.ts @@ -23,16 +23,13 @@ export namespace Organization { export namespace Changeable { export type Invite = OrganizationChangeable.Invite } - export const type = Creatable.type.omit(["permissions", "user"]).extend({ + export const type = Creatable.type.omit(["permissions", "id"]).extend({ id: Identifier.type, - name: isly.string(/.+/), 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), - // user: }) - // export const type = isly.object({}) export const is = type.is export const flaw = type.flaw } From 2c6a487a9fd0fc5763772ba1750b97196cdc7be5 Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Wed, 20 Nov 2024 11:46:24 +0100 Subject: [PATCH 04/10] user as string to invite on org --- Organization/Creatable.ts | 3 +++ Organization/index.ts | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Organization/Creatable.ts b/Organization/Creatable.ts index 4fc5ad6..c147078 100644 --- a/Organization/Creatable.ts +++ b/Organization/Creatable.ts @@ -1,9 +1,11 @@ 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 { @@ -11,6 +13,7 @@ export namespace Creatable { id: Identifier.type.optional(), name: isly.string(/.+/), permissions: isly.array(isly.string(/.+/)).optional(), + user: Email.type, }) export const is = type.is export const flaw = type.flaw diff --git a/Organization/index.ts b/Organization/index.ts index 237e9b7..879359a 100644 --- a/Organization/index.ts +++ b/Organization/index.ts @@ -5,12 +5,12 @@ import { Changeable as OrganizationChangeable } from "./Changeable" import { Creatable as OrganizationCreatable } from "./Creatable" import { Identifier as OrganizationIdentifier } from "./Identifier" -export interface Organization extends Omit { +export interface Organization extends Omit { id: Organization.Identifier - created: isoly.DateTime - modified: isoly.DateTime users: Email[] permissions: string[] + created: isoly.DateTime + modified: isoly.DateTime } export namespace Organization { @@ -23,12 +23,12 @@ export namespace Organization { export namespace Changeable { export type Invite = OrganizationChangeable.Invite } - export const type = Creatable.type.omit(["permissions", "id"]).extend({ + export const type = Creatable.type.omit(["permissions", "id", "user"]).extend({ id: Identifier.type, + 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 From ba370d3c76891d0aad9380dbd0d9dedaecd9b86b Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Thu, 21 Nov 2024 09:10:07 +0100 Subject: [PATCH 05/10] audit --- package-lock.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04529af..d5a70de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2461,10 +2461,11 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", From 92d5c0077ba89150fcc2a2015a44b095ec31ee2f Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Thu, 21 Nov 2024 10:29:34 +0100 Subject: [PATCH 06/10] selfSignOn optional --- Application/Creatable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Creatable.ts b/Application/Creatable.ts index 032dfeb..ba29652 100644 --- a/Application/Creatable.ts +++ b/Application/Creatable.ts @@ -7,7 +7,7 @@ export interface Creatable { export namespace Creatable { export const type = isly.object({ name: isly.string(/.+/), - selfSignOn: isly.boolean(), + selfSignOn: isly.boolean().optional(), permissions: isly.array(isly.string(/.+/)).optional(), }) export const is = type.is From 73a0acbcda27a78501cedfe731abfbc231732b56 Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Thu, 21 Nov 2024 11:53:10 +0100 Subject: [PATCH 07/10] optional user --- Organization/Creatable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Organization/Creatable.ts b/Organization/Creatable.ts index c147078..b3b385b 100644 --- a/Organization/Creatable.ts +++ b/Organization/Creatable.ts @@ -13,7 +13,7 @@ export namespace Creatable { id: Identifier.type.optional(), name: isly.string(/.+/), permissions: isly.array(isly.string(/.+/)).optional(), - user: Email.type, + user: Email.type.optional(), }) export const is = type.is export const flaw = type.flaw From ab42d359b0568d966703cd4c0621b2e2d6bfba53 Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Thu, 21 Nov 2024 16:47:32 +0100 Subject: [PATCH 08/10] client reflects api --- ClientCollection/Organization.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ClientCollection/Organization.ts b/ClientCollection/Organization.ts index 5a347ab..38b9542 100644 --- a/ClientCollection/Organization.ts +++ b/ClientCollection/Organization.ts @@ -22,7 +22,11 @@ export class Organization extends rest.Collection { ) 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 { const result = await this.client.get( From 56062288aa466a2c56a9f8992c4db7b5a0832f4b Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Fri, 22 Nov 2024 09:02:10 +0100 Subject: [PATCH 09/10] exports --- Application/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Application/index.ts b/Application/index.ts index c3ca24f..f5daa4c 100644 --- a/Application/index.ts +++ b/Application/index.ts @@ -13,12 +13,9 @@ export interface Application extends Omit } 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 import Identifier = ApplicationIdentifier + export import Creatable = ApplicationCreatable + export import Changeable = ApplicationChangeable export const type = Creatable.type.omit(["permissions"]).extend({ id: Identifier.type, permissions: isly.array(isly.string()), From adb1eb45359519556d75a16d10d801f361cd9ca2 Mon Sep 17 00:00:00 2001 From: Elias Eriksson Date: Fri, 22 Nov 2024 10:02:25 +0100 Subject: [PATCH 10/10] organization exports --- Organization/index.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Organization/index.ts b/Organization/index.ts index 879359a..0bb6bf4 100644 --- a/Organization/index.ts +++ b/Organization/index.ts @@ -14,15 +14,9 @@ export interface Organization extends Omit({ id: Identifier.type, users: isly.array(Email.type),