@wtfalch/foundry 0.4.0 → 0.6.0

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 (76) hide show
  1. package/dist/bootstrap/bootstrap.d.ts +111 -0
  2. package/dist/bootstrap/bootstrap.js +323 -0
  3. package/dist/bootstrap/declare.d.ts +36 -0
  4. package/dist/bootstrap/declare.js +99 -0
  5. package/dist/bootstrap/drive.d.ts +40 -0
  6. package/dist/bootstrap/drive.js +51 -0
  7. package/dist/bootstrap/index.d.ts +3 -0
  8. package/dist/bootstrap/index.js +1 -0
  9. package/dist/calls-sfu-deploy-support.d.ts +17 -6
  10. package/dist/calls-sfu-deploy-support.js +19 -7
  11. package/dist/calls-sfu-keys.d.ts +21 -0
  12. package/dist/calls-sfu-keys.js +27 -0
  13. package/dist/calls-sfu-ssh-adapter.d.ts +55 -0
  14. package/dist/calls-sfu-ssh-adapter.js +78 -0
  15. package/dist/calls-sfu-ssh-client.d.ts +49 -0
  16. package/dist/calls-sfu-ssh-client.js +82 -0
  17. package/dist/calls-sfu.d.ts +36 -12
  18. package/dist/calls-sfu.js +41 -9
  19. package/dist/index.d.ts +38 -7
  20. package/dist/index.js +20 -4
  21. package/dist/migrations/0016_platform.sql +61 -0
  22. package/dist/migrations/0017_requested_changes.sql +42 -0
  23. package/dist/migrations/0018_platform_apply.sql +19 -0
  24. package/dist/migrations/0019_mail_owner_mailbox.sql +15 -0
  25. package/dist/migrations/0020_mail_apps.sql +7 -0
  26. package/dist/migrations/0021_mail_role_mailboxes.sql +6 -0
  27. package/dist/org.d.ts +81 -0
  28. package/dist/org.js +96 -0
  29. package/dist/plan/agora.d.ts +77 -0
  30. package/dist/plan/agora.js +127 -0
  31. package/dist/plan/cloudflared-connector.d.ts +70 -0
  32. package/dist/plan/cloudflared-connector.js +106 -0
  33. package/dist/plan/diff.d.ts +20 -3
  34. package/dist/plan/diff.js +713 -115
  35. package/dist/plan/executor.d.ts +680 -172
  36. package/dist/plan/executor.js +755 -189
  37. package/dist/plan/index.d.ts +28 -5
  38. package/dist/plan/index.js +15 -2
  39. package/dist/plan/jobs-scheduler-http.d.ts +29 -0
  40. package/dist/plan/jobs-scheduler-http.js +50 -0
  41. package/dist/plan/live.d.ts +51 -2
  42. package/dist/plan/live.js +8 -0
  43. package/dist/plan/mail-copy.d.ts +125 -0
  44. package/dist/plan/mail-copy.js +166 -0
  45. package/dist/plan/mail-identity-allowlist.d.ts +50 -0
  46. package/dist/plan/mail-identity-allowlist.js +11 -0
  47. package/dist/plan/mail-identity.d.ts +68 -0
  48. package/dist/plan/mail-identity.js +17 -0
  49. package/dist/plan/plan-apply.d.ts +197 -3
  50. package/dist/plan/plan-apply.js +278 -9
  51. package/dist/plan/platform-diff.d.ts +487 -0
  52. package/dist/plan/platform-diff.js +1220 -0
  53. package/dist/plan/platform-org-ports.d.ts +50 -0
  54. package/dist/plan/platform-org-ports.js +70 -0
  55. package/dist/plan/platform-org.d.ts +121 -0
  56. package/dist/plan/platform-org.js +115 -0
  57. package/dist/plan/platform-providers.d.ts +615 -0
  58. package/dist/plan/platform-providers.js +4410 -0
  59. package/dist/plan/platform-sfu.d.ts +128 -0
  60. package/dist/plan/platform-sfu.js +142 -0
  61. package/dist/plan/providers-readers.js +22 -1
  62. package/dist/plan/zitadel-machine-user.d.ts +83 -0
  63. package/dist/plan/zitadel-machine-user.js +238 -0
  64. package/dist/plan.d.ts +6 -0
  65. package/dist/platform.d.ts +55 -0
  66. package/dist/platform.js +46 -0
  67. package/dist/requested-changes.d.ts +118 -0
  68. package/dist/requested-changes.js +125 -0
  69. package/dist/slug.js +15 -2
  70. package/dist/store/audit.js +4 -2
  71. package/dist/store/postgres.d.ts +29 -1
  72. package/dist/store/postgres.js +203 -4
  73. package/dist/store/schema.d.ts +755 -0
  74. package/dist/store/schema.js +70 -0
  75. package/dist/store.d.ts +53 -0
  76. package/package.json +1 -1
@@ -12,6 +12,19 @@ export const declaredOrgs = pgTable('foundry_declared_orgs', {
12
12
  domain: text('domain'),
13
13
  mailMode: text('mail_mode').notNull().default('off'),
14
14
  mailUsesDomain: boolean('mail_uses_domain').notNull().default(false),
15
+ // MailConfig (org.ts, #162). null until an operator declares one -- the
16
+ // mailbox itself is blocked, not guessed, until it is.
17
+ ownerMailboxAddress: text('owner_mailbox_address'),
18
+ // Defaults to 'no-reply', the same literal `0019_mail_owner_mailbox.sql`
19
+ // and org.ts's `DEFAULT_NO_REPLY_LOCAL_PART` use.
20
+ noReplyLocalPart: text('no_reply_local_part').notNull().default('no-reply'),
21
+ // MailConfig.mailApps (org.ts, #34). Which ZITADEL apps in the org's
22
+ // audience project may read a person's mail; defaults to DEFAULT_MAIL_APPS
23
+ // ('agora', 'webmail') so every existing org keeps its current behaviour.
24
+ mailApps: jsonb('mail_apps').notNull().default(['agora', 'webmail']).$type(),
25
+ // MailConfig.roleMailboxes (org.ts, #230). Local parts of the role mailboxes
26
+ // pre-created on the org's mail domain; empty by default.
27
+ roleMailboxes: jsonb('role_mailboxes').notNull().default([]).$type(),
15
28
  chatUsesDomain: boolean('chat_uses_domain').notNull().default(false),
16
29
  callsEnabled: boolean('calls_enabled').notNull().default(false),
17
30
  callsUsesDomain: boolean('calls_uses_domain').notNull().default(false),
@@ -88,4 +101,61 @@ export const foundryAuditEvents = pgTable('foundry_audit_events', {
88
101
  outcome: text('outcome').$type(),
89
102
  reason: text('reason'),
90
103
  plan: jsonb('plan').$type(),
104
+ /** `'platform'` for a platform plan or apply (`migrations/0018_platform_apply.sql`); null for an org's row. */
105
+ target: text('target').$type(),
106
+ });
107
+ /**
108
+ * Mirrors `migrations/0016_platform.sql`, which is the source of truth: the
109
+ * SQL carries the singleton `check (id)` constraint drizzle-kit does not
110
+ * generate here (this package has no drizzle-kit journal, per the top of
111
+ * this file). `id` is always `true` -- see that migration's own comment.
112
+ */
113
+ export const foundryDeclaredPlatform = pgTable('foundry_declared_platform', {
114
+ id: boolean('id').primaryKey().default(true),
115
+ ownerOrgId: text('owner_org_id').notNull(),
116
+ apex: text('apex').notNull(),
117
+ authEnabled: boolean('auth_enabled').notNull().default(false),
118
+ authHostname: text('auth_hostname').notNull(),
119
+ authGitRef: text('auth_git_ref').notNull().default(''),
120
+ mailEnabled: boolean('mail_enabled').notNull().default(false),
121
+ mailHostname: text('mail_hostname').notNull(),
122
+ mailGitRef: text('mail_git_ref').notNull().default(''),
123
+ sfuEnabled: boolean('sfu_enabled').notNull().default(false),
124
+ sfuHostname: text('sfu_hostname').notNull(),
125
+ sfuGitRef: text('sfu_git_ref').notNull().default(''),
126
+ filesEnabled: boolean('files_enabled').notNull().default(false),
127
+ filesHostname: text('files_hostname').notNull(),
128
+ filesGitRef: text('files_git_ref').notNull().default(''),
129
+ aiEnabled: boolean('ai_enabled').notNull().default(false),
130
+ aiHostname: text('ai_hostname').notNull(),
131
+ aiGitRef: text('ai_git_ref').notNull().default(''),
132
+ jobsEnabled: boolean('jobs_enabled').notNull().default(false),
133
+ jobsHostname: text('jobs_hostname').notNull(),
134
+ jobsGitRef: text('jobs_git_ref').notNull().default(''),
135
+ integrationsEnabled: boolean('integrations_enabled').notNull().default(false),
136
+ integrationsHostname: text('integrations_hostname').notNull(),
137
+ integrationsGitRef: text('integrations_git_ref').notNull().default(''),
138
+ archonEnabled: boolean('archon_enabled').notNull().default(false),
139
+ archonHostname: text('archon_hostname').notNull(),
140
+ archonGitRef: text('archon_git_ref').notNull().default(''),
141
+ /** `migrations/0018_platform_apply.sql`: the platform's applied state, `system:kind:key` to provider id. */
142
+ serviceIds: jsonb('service_ids').$type().notNull().default({}),
143
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
144
+ updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
145
+ });
146
+ /**
147
+ * Mirrors `migrations/0017_requested_changes.sql`, which is the source of
148
+ * truth: the SQL carries the `field`/`state` CHECKs drizzle-kit does not
149
+ * generate here (this package has no drizzle-kit journal, per the top of
150
+ * this file). `value` holds only the field-specific payload -- `field`
151
+ * itself is the discriminator column, not repeated inside the jsonb.
152
+ */
153
+ export const foundryRequestedChanges = pgTable('foundry_requested_changes', {
154
+ id: bigserial('id', { mode: 'number' }).primaryKey(),
155
+ orgId: text('org_id').notNull(),
156
+ field: text('field').notNull(),
157
+ value: jsonb('value').notNull().$type(),
158
+ requestedBy: text('requested_by').notNull(),
159
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
160
+ state: text('state').notNull().default('needs_approval'),
91
161
  });
package/dist/store.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { DeclaredOrg, OrgId } from './org.js';
2
+ import type { DeclaredPlatform } from './platform.js';
3
+ import type { RequestedChange, RequestedChangeValue } from './requested-changes.js';
2
4
  import type { AppliedState } from './state.js';
3
5
  /**
4
6
  * The persistence seam https://github.com/wtfalch/foundry/issues/18
@@ -12,6 +14,13 @@ import type { AppliedState } from './state.js';
12
14
  export interface DeclaredOrgStore {
13
15
  create(org: DeclaredOrg): Promise<void>;
14
16
  get(id: OrgId): Promise<DeclaredOrg | null>;
17
+ /**
18
+ * Every declared org, ordered by display name (#133). The read path a
19
+ * billing admin area (or anything else that just wants the roster) uses
20
+ * instead of reading the store's own table by hand -- Archon's
21
+ * `listCustomers` was doing exactly that before this existed.
22
+ */
23
+ list(): Promise<DeclaredOrg[]>;
15
24
  /** Whether any org already holds this slug. `slugFromName` asks it. */
16
25
  slugTaken(slug: string): Promise<boolean>;
17
26
  /**
@@ -43,3 +52,47 @@ export interface DeclaredOrgStore {
43
52
  */
44
53
  delete(id: OrgId): Promise<void>;
45
54
  }
55
+ /**
56
+ * The persistence seam for #166's {@link DeclaredPlatform}, mirroring
57
+ * {@link DeclaredOrgStore}'s split beside it. There is exactly one declared
58
+ * platform -- `get`/`put` take no id, and `migrations/0016_platform.sql`'s
59
+ * singleton table refuses a second row at the database level.
60
+ */
61
+ export interface PlatformStore {
62
+ /** `null` until an operator declares the platform for the first time. */
63
+ get(): Promise<DeclaredPlatform | null>;
64
+ /** Creates the platform on the first call, replaces it on every later one. */
65
+ put(platform: DeclaredPlatform): Promise<void>;
66
+ /**
67
+ * The platform's applied state (#167): the provider ids its apply made or
68
+ * adopted, keyed `system:kind:key` like `AppliedState.serviceIds`. `{}`
69
+ * before the first apply. `put` never touches it.
70
+ */
71
+ getServiceIds(): Promise<Record<string, string>>;
72
+ /** Replaces the recorded ids. A no-op until the platform is declared. */
73
+ putServiceIds(serviceIds: Record<string, string>): Promise<void>;
74
+ }
75
+ /**
76
+ * The persistence seam for #178's {@link RequestedChange}: a company's own
77
+ * Boule requests a setting change on its declared org, foundry classifies
78
+ * and stores it, and archon reads it back to drive its own approve/apply
79
+ * workflow.
80
+ */
81
+ export interface RequestedChangeStore {
82
+ /**
83
+ * Classifies `value` against `org`'s current state
84
+ * (`requested-changes.js`'s `classifyChange`) and stores the request,
85
+ * keyed by a generated id. Throws `requested-changes.js`'s
86
+ * `RequestedChangeError` for a field outside the whitelist -- never
87
+ * silently drops the write.
88
+ */
89
+ create(input: {
90
+ orgId: OrgId;
91
+ org: DeclaredOrg;
92
+ value: RequestedChangeValue;
93
+ requestedBy: string;
94
+ }): Promise<RequestedChange>;
95
+ get(id: number): Promise<RequestedChange | null>;
96
+ /** Every request an org has made, oldest first. */
97
+ listForOrg(orgId: OrgId): Promise<RequestedChange[]>;
98
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/foundry",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
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",