@wtfalch/foundry 0.4.0 → 0.5.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 (66) hide show
  1. package/dist/bootstrap/bootstrap.d.ts +96 -0
  2. package/dist/bootstrap/bootstrap.js +285 -0
  3. package/dist/bootstrap/declare.d.ts +36 -0
  4. package/dist/bootstrap/declare.js +94 -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 +9 -6
  10. package/dist/calls-sfu-deploy-support.js +9 -6
  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 +5 -4
  18. package/dist/calls-sfu.js +5 -4
  19. package/dist/index.d.ts +31 -6
  20. package/dist/index.js +16 -3
  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/org.js +8 -0
  25. package/dist/plan/agora.d.ts +77 -0
  26. package/dist/plan/agora.js +127 -0
  27. package/dist/plan/cloudflared-connector.d.ts +70 -0
  28. package/dist/plan/cloudflared-connector.js +106 -0
  29. package/dist/plan/diff.d.ts +20 -3
  30. package/dist/plan/diff.js +631 -116
  31. package/dist/plan/executor.d.ts +475 -168
  32. package/dist/plan/executor.js +543 -175
  33. package/dist/plan/index.d.ts +22 -5
  34. package/dist/plan/index.js +12 -2
  35. package/dist/plan/jobs-scheduler-http.d.ts +29 -0
  36. package/dist/plan/jobs-scheduler-http.js +50 -0
  37. package/dist/plan/live.d.ts +51 -2
  38. package/dist/plan/live.js +8 -0
  39. package/dist/plan/plan-apply.d.ts +192 -3
  40. package/dist/plan/plan-apply.js +278 -9
  41. package/dist/plan/platform-diff.d.ts +312 -0
  42. package/dist/plan/platform-diff.js +867 -0
  43. package/dist/plan/platform-org-ports.d.ts +50 -0
  44. package/dist/plan/platform-org-ports.js +70 -0
  45. package/dist/plan/platform-org.d.ts +120 -0
  46. package/dist/plan/platform-org.js +115 -0
  47. package/dist/plan/platform-providers.d.ts +501 -0
  48. package/dist/plan/platform-providers.js +3029 -0
  49. package/dist/plan/platform-sfu.d.ts +93 -0
  50. package/dist/plan/platform-sfu.js +100 -0
  51. package/dist/plan/providers-readers.js +22 -1
  52. package/dist/plan/zitadel-machine-user.d.ts +34 -0
  53. package/dist/plan/zitadel-machine-user.js +95 -0
  54. package/dist/plan.d.ts +6 -0
  55. package/dist/platform.d.ts +55 -0
  56. package/dist/platform.js +46 -0
  57. package/dist/requested-changes.d.ts +108 -0
  58. package/dist/requested-changes.js +95 -0
  59. package/dist/slug.js +15 -2
  60. package/dist/store/audit.js +4 -2
  61. package/dist/store/postgres.d.ts +29 -1
  62. package/dist/store/postgres.js +172 -2
  63. package/dist/store/schema.d.ts +683 -0
  64. package/dist/store/schema.js +57 -0
  65. package/dist/store.d.ts +46 -0
  66. package/package.json +1 -1
@@ -88,4 +88,61 @@ export const foundryAuditEvents = pgTable('foundry_audit_events', {
88
88
  outcome: text('outcome').$type(),
89
89
  reason: text('reason'),
90
90
  plan: jsonb('plan').$type(),
91
+ /** `'platform'` for a platform plan or apply (`migrations/0018_platform_apply.sql`); null for an org's row. */
92
+ target: text('target').$type(),
93
+ });
94
+ /**
95
+ * Mirrors `migrations/0016_platform.sql`, which is the source of truth: the
96
+ * SQL carries the singleton `check (id)` constraint drizzle-kit does not
97
+ * generate here (this package has no drizzle-kit journal, per the top of
98
+ * this file). `id` is always `true` -- see that migration's own comment.
99
+ */
100
+ export const foundryDeclaredPlatform = pgTable('foundry_declared_platform', {
101
+ id: boolean('id').primaryKey().default(true),
102
+ ownerOrgId: text('owner_org_id').notNull(),
103
+ apex: text('apex').notNull(),
104
+ authEnabled: boolean('auth_enabled').notNull().default(false),
105
+ authHostname: text('auth_hostname').notNull(),
106
+ authGitRef: text('auth_git_ref').notNull().default(''),
107
+ mailEnabled: boolean('mail_enabled').notNull().default(false),
108
+ mailHostname: text('mail_hostname').notNull(),
109
+ mailGitRef: text('mail_git_ref').notNull().default(''),
110
+ sfuEnabled: boolean('sfu_enabled').notNull().default(false),
111
+ sfuHostname: text('sfu_hostname').notNull(),
112
+ sfuGitRef: text('sfu_git_ref').notNull().default(''),
113
+ filesEnabled: boolean('files_enabled').notNull().default(false),
114
+ filesHostname: text('files_hostname').notNull(),
115
+ filesGitRef: text('files_git_ref').notNull().default(''),
116
+ aiEnabled: boolean('ai_enabled').notNull().default(false),
117
+ aiHostname: text('ai_hostname').notNull(),
118
+ aiGitRef: text('ai_git_ref').notNull().default(''),
119
+ jobsEnabled: boolean('jobs_enabled').notNull().default(false),
120
+ jobsHostname: text('jobs_hostname').notNull(),
121
+ jobsGitRef: text('jobs_git_ref').notNull().default(''),
122
+ integrationsEnabled: boolean('integrations_enabled').notNull().default(false),
123
+ integrationsHostname: text('integrations_hostname').notNull(),
124
+ integrationsGitRef: text('integrations_git_ref').notNull().default(''),
125
+ archonEnabled: boolean('archon_enabled').notNull().default(false),
126
+ archonHostname: text('archon_hostname').notNull(),
127
+ archonGitRef: text('archon_git_ref').notNull().default(''),
128
+ /** `migrations/0018_platform_apply.sql`: the platform's applied state, `system:kind:key` to provider id. */
129
+ serviceIds: jsonb('service_ids').$type().notNull().default({}),
130
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
131
+ updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
132
+ });
133
+ /**
134
+ * Mirrors `migrations/0017_requested_changes.sql`, which is the source of
135
+ * truth: the SQL carries the `field`/`state` CHECKs drizzle-kit does not
136
+ * generate here (this package has no drizzle-kit journal, per the top of
137
+ * this file). `value` holds only the field-specific payload -- `field`
138
+ * itself is the discriminator column, not repeated inside the jsonb.
139
+ */
140
+ export const foundryRequestedChanges = pgTable('foundry_requested_changes', {
141
+ id: bigserial('id', { mode: 'number' }).primaryKey(),
142
+ orgId: text('org_id').notNull(),
143
+ field: text('field').notNull(),
144
+ value: jsonb('value').notNull().$type(),
145
+ requestedBy: text('requested_by').notNull(),
146
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
147
+ state: text('state').notNull().default('needs_approval'),
91
148
  });
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
@@ -43,3 +45,47 @@ export interface DeclaredOrgStore {
43
45
  */
44
46
  delete(id: OrgId): Promise<void>;
45
47
  }
48
+ /**
49
+ * The persistence seam for #166's {@link DeclaredPlatform}, mirroring
50
+ * {@link DeclaredOrgStore}'s split beside it. There is exactly one declared
51
+ * platform -- `get`/`put` take no id, and `migrations/0016_platform.sql`'s
52
+ * singleton table refuses a second row at the database level.
53
+ */
54
+ export interface PlatformStore {
55
+ /** `null` until an operator declares the platform for the first time. */
56
+ get(): Promise<DeclaredPlatform | null>;
57
+ /** Creates the platform on the first call, replaces it on every later one. */
58
+ put(platform: DeclaredPlatform): Promise<void>;
59
+ /**
60
+ * The platform's applied state (#167): the provider ids its apply made or
61
+ * adopted, keyed `system:kind:key` like `AppliedState.serviceIds`. `{}`
62
+ * before the first apply. `put` never touches it.
63
+ */
64
+ getServiceIds(): Promise<Record<string, string>>;
65
+ /** Replaces the recorded ids. A no-op until the platform is declared. */
66
+ putServiceIds(serviceIds: Record<string, string>): Promise<void>;
67
+ }
68
+ /**
69
+ * The persistence seam for #178's {@link RequestedChange}: a company's own
70
+ * Boule requests a setting change on its declared org, foundry classifies
71
+ * and stores it, and archon reads it back to drive its own approve/apply
72
+ * workflow.
73
+ */
74
+ export interface RequestedChangeStore {
75
+ /**
76
+ * Classifies `value` against `org`'s current state
77
+ * (`requested-changes.js`'s `classifyChange`) and stores the request,
78
+ * keyed by a generated id. Throws `requested-changes.js`'s
79
+ * `RequestedChangeError` for a field outside the whitelist -- never
80
+ * silently drops the write.
81
+ */
82
+ create(input: {
83
+ orgId: OrgId;
84
+ org: DeclaredOrg;
85
+ value: RequestedChangeValue;
86
+ requestedBy: string;
87
+ }): Promise<RequestedChange>;
88
+ get(id: number): Promise<RequestedChange | null>;
89
+ /** Every request an org has made, oldest first. */
90
+ listForOrg(orgId: OrgId): Promise<RequestedChange[]>;
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/foundry",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",