@wtfalch/foundry 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/bootstrap/declare.d.ts +2 -2
  2. package/dist/bootstrap/declare.js +6 -6
  3. package/dist/index.d.ts +3 -3
  4. package/dist/index.js +2 -2
  5. package/dist/migrations/0034_owners.sql +42 -0
  6. package/dist/migrations/0035_chat_on_by_default.sql +10 -0
  7. package/dist/org.d.ts +80 -17
  8. package/dist/org.js +221 -18
  9. package/dist/plan/agora.d.ts +19 -1
  10. package/dist/plan/agora.js +37 -2
  11. package/dist/plan/chat-matrix.d.ts +99 -0
  12. package/dist/plan/chat-matrix.js +194 -0
  13. package/dist/plan/diff.d.ts +5 -3
  14. package/dist/plan/diff.js +143 -83
  15. package/dist/plan/entry-ai-key.d.ts +58 -0
  16. package/dist/plan/entry-ai-key.js +209 -0
  17. package/dist/plan/entry-files-key.d.ts +82 -0
  18. package/dist/plan/entry-files-key.js +327 -0
  19. package/dist/plan/executor.d.ts +244 -16
  20. package/dist/plan/executor.js +866 -84
  21. package/dist/plan/hostnames.d.ts +14 -1
  22. package/dist/plan/hostnames.js +26 -1
  23. package/dist/plan/index.d.ts +1 -0
  24. package/dist/plan/index.js +1 -0
  25. package/dist/plan/plan-apply.d.ts +2 -0
  26. package/dist/plan/plan-apply.js +42 -2
  27. package/dist/plan/platform-org.d.ts +17 -5
  28. package/dist/plan/platform-org.js +15 -7
  29. package/dist/plan/platform-providers.js +4 -3
  30. package/dist/plan/proxy-labels.d.ts +42 -0
  31. package/dist/plan/proxy-labels.js +73 -0
  32. package/dist/plan/zitadel-machine-user.d.ts +5 -1
  33. package/dist/plan/zitadel-machine-user.js +5 -1
  34. package/dist/plan/zitadel-project-roles.d.ts +25 -0
  35. package/dist/plan/zitadel-project-roles.js +104 -0
  36. package/dist/store/postgres.js +4 -17
  37. package/dist/store/schema.d.ts +13 -45
  38. package/dist/store/schema.js +5 -8
  39. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { and, asc, eq, sql } from 'drizzle-orm';
2
- import { APP_ENTRY_KEY, DEFAULT_MAIL_APPS, DEFAULT_NO_REPLY_LOCAL_PART, validateBuyerIdentity, validateDomain, validateHosting, validateMail, validateOwner, validateSite, } from '../org.js';
2
+ import { APP_ENTRY_KEY, DEFAULT_MAIL_APPS, DEFAULT_NO_REPLY_LOCAL_PART, validateBuyerIdentity, validateDomain, validateHosting, validateMail, validateOwners, validateSite, } from '../org.js';
3
3
  import { lockedHostnames } from '../plan/locked-hostnames.js';
4
4
  import { validatePlatform } from '../platform.js';
5
5
  import { RequestedChangeError, classifyChange } from '../requested-changes.js';
@@ -99,7 +99,7 @@ function rowToOrg(row) {
99
99
  adoptedApp: row.adoptedAppForm
100
100
  ? { form: row.adoptedAppForm }
101
101
  : null,
102
- owner: rowToOwner(row),
102
+ owners: row.owners ?? [],
103
103
  test: row.isTest,
104
104
  };
105
105
  }
@@ -142,9 +142,7 @@ function orgToRow(org) {
142
142
  vatRegistered: org.buyer.vatRegistered,
143
143
  bespokeAppRepo: org.bespokeAppRepo,
144
144
  adoptedAppForm: org.adoptedApp?.form ?? null,
145
- ownerEmail: org.owner?.email ?? null,
146
- ownerGivenName: org.owner?.givenName ?? null,
147
- ownerFamilyName: org.owner?.familyName ?? null,
145
+ owners: org.owners,
148
146
  isTest: org.test,
149
147
  };
150
148
  }
@@ -173,17 +171,6 @@ function rowToBuyer(row) {
173
171
  vatRegistered: row.vatRegistered,
174
172
  };
175
173
  }
176
- /**
177
- * Reassembles `DeclaredOrg.owner` from the row's three separate nullable
178
- * columns -- present only when all three are, same "all parts or none"
179
- * pattern {@link rowToBuyer} uses for the buyer's address.
180
- */
181
- function rowToOwner(row) {
182
- const { ownerEmail, ownerGivenName, ownerFamilyName } = row;
183
- if (ownerEmail === null || ownerGivenName === null || ownerFamilyName === null)
184
- return null;
185
- return { email: ownerEmail, givenName: ownerGivenName, familyName: ownerFamilyName };
186
- }
187
174
  /**
188
175
  * `DeclaredOrgStore` (`../store.ts`) on Postgres, for #18: create, read and
189
176
  * edit a {@link DeclaredOrg}, and read and write the {@link AppliedState}
@@ -272,7 +259,7 @@ export function createPostgresDeclaredOrgStore(db) {
272
259
  // Same place `requireValidHosting` checks hosting, on both `create` and
273
260
  // the merged result of `update`.
274
261
  function requireValidOwner(org) {
275
- const reason = validateOwner(org.owner);
262
+ const reason = validateOwners(org.owners);
276
263
  if (reason)
277
264
  throw new DeclaredOrgError(`owner invalid: ${reason}`);
278
265
  }
@@ -1,4 +1,4 @@
1
- import type { AppEnvSource, HostingEntry, IssuerApp } from '../org.js';
1
+ import type { AppEnvSource, HostingEntry, IssuerApp, OwnerIdentity } from '../org.js';
2
2
  import type { Plan } from '../plan.js';
3
3
  import type { Checkpoint } from '../state.js';
4
4
  /**
@@ -754,57 +754,25 @@ export declare const declaredOrgs: import("drizzle-orm/pg-core").PgTableWithColu
754
754
  identity: undefined;
755
755
  generated: undefined;
756
756
  }, {}, {}>;
757
- ownerEmail: import("drizzle-orm/pg-core").PgColumn<{
758
- name: "owner_email";
757
+ owners: import("drizzle-orm/pg-core").PgColumn<{
758
+ name: "owners";
759
759
  tableName: "foundry_declared_orgs";
760
- dataType: "string";
761
- columnType: "PgText";
762
- data: string;
763
- driverParam: string;
764
- notNull: false;
765
- hasDefault: false;
766
- isPrimaryKey: false;
767
- isAutoincrement: false;
768
- hasRuntimeDefault: false;
769
- enumValues: [string, ...string[]];
770
- baseColumn: never;
771
- identity: undefined;
772
- generated: undefined;
773
- }, {}, {}>;
774
- ownerGivenName: import("drizzle-orm/pg-core").PgColumn<{
775
- name: "owner_given_name";
776
- tableName: "foundry_declared_orgs";
777
- dataType: "string";
778
- columnType: "PgText";
779
- data: string;
780
- driverParam: string;
781
- notNull: false;
782
- hasDefault: false;
783
- isPrimaryKey: false;
784
- isAutoincrement: false;
785
- hasRuntimeDefault: false;
786
- enumValues: [string, ...string[]];
787
- baseColumn: never;
788
- identity: undefined;
789
- generated: undefined;
790
- }, {}, {}>;
791
- ownerFamilyName: import("drizzle-orm/pg-core").PgColumn<{
792
- name: "owner_family_name";
793
- tableName: "foundry_declared_orgs";
794
- dataType: "string";
795
- columnType: "PgText";
796
- data: string;
797
- driverParam: string;
798
- notNull: false;
799
- hasDefault: false;
760
+ dataType: "json";
761
+ columnType: "PgJsonb";
762
+ data: OwnerIdentity[];
763
+ driverParam: unknown;
764
+ notNull: true;
765
+ hasDefault: true;
800
766
  isPrimaryKey: false;
801
767
  isAutoincrement: false;
802
768
  hasRuntimeDefault: false;
803
- enumValues: [string, ...string[]];
769
+ enumValues: undefined;
804
770
  baseColumn: never;
805
771
  identity: undefined;
806
772
  generated: undefined;
807
- }, {}, {}>;
773
+ }, {}, {
774
+ $type: OwnerIdentity[];
775
+ }>;
808
776
  isTest: import("drizzle-orm/pg-core").PgColumn<{
809
777
  name: "is_test";
810
778
  tableName: "foundry_declared_orgs";
@@ -27,7 +27,7 @@ export const declaredOrgs = pgTable('foundry_declared_orgs', {
27
27
  // MailConfig.roleMailboxes (org.ts, #230). Local parts of the role mailboxes
28
28
  // pre-created on the org's mail domain; empty by default.
29
29
  roleMailboxes: jsonb('role_mailboxes').notNull().default([]).$type(),
30
- chatEnabled: boolean('chat_enabled').notNull().default(false),
30
+ chatEnabled: boolean('chat_enabled').notNull().default(true),
31
31
  chatUsesDomain: boolean('chat_uses_domain').notNull().default(false),
32
32
  callsEnabled: boolean('calls_enabled').notNull().default(false),
33
33
  callsUsesDomain: boolean('calls_uses_domain').notNull().default(false),
@@ -78,13 +78,10 @@ export const declaredOrgs = pgTable('foundry_declared_orgs', {
78
78
  vatRegistered: boolean('vat_registered'),
79
79
  bespokeAppRepo: text('bespoke_app_repo'),
80
80
  adoptedAppForm: text('adopted_app_form'),
81
- // OwnerIdentity (org.ts): the org's owner, invited by ZITADEL email. All
82
- // three nullable -- a brand new org has none of them, reassembled as one
83
- // object only once all three are non-null (same shape as BuyerIdentity's
84
- // own contact fields above).
85
- ownerEmail: text('owner_email'),
86
- ownerGivenName: text('owner_given_name'),
87
- ownerFamilyName: text('owner_family_name'),
81
+ // OwnerIdentity[] (org.ts): the org's current owners, in order (the first
82
+ // is the primary). jsonb, like `hosting_entries`: an ordered list read and
83
+ // written whole with the org, never queried by owner.
84
+ owners: jsonb('owners').notNull().default([]).$type(),
88
85
  // `test: boolean` (org.ts): only a test org can be destroyed. A brand new
89
86
  // org defaults to real (false).
90
87
  isTest: boolean('is_test').notNull().default(false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/foundry",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "description": "Foundry's SDK: the declared org's types, the plan and apply contracts, and the state store's interface.",
5
5
  "repository": {
6
6
  "type": "git",