@wtfalch/foundry 0.3.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.
- package/dist/bootstrap/bootstrap.d.ts +96 -0
- package/dist/bootstrap/bootstrap.js +285 -0
- package/dist/bootstrap/declare.d.ts +36 -0
- package/dist/bootstrap/declare.js +94 -0
- package/dist/bootstrap/drive.d.ts +40 -0
- package/dist/bootstrap/drive.js +51 -0
- package/dist/bootstrap/index.d.ts +3 -0
- package/dist/bootstrap/index.js +1 -0
- package/dist/calls-sfu-deploy-support.d.ts +9 -6
- package/dist/calls-sfu-deploy-support.js +9 -6
- package/dist/calls-sfu-keys.d.ts +21 -0
- package/dist/calls-sfu-keys.js +27 -0
- package/dist/calls-sfu-ssh-adapter.d.ts +55 -0
- package/dist/calls-sfu-ssh-adapter.js +78 -0
- package/dist/calls-sfu-ssh-client.d.ts +49 -0
- package/dist/calls-sfu-ssh-client.js +82 -0
- package/dist/calls-sfu.d.ts +22 -4
- package/dist/calls-sfu.js +22 -4
- package/dist/index.d.ts +31 -6
- package/dist/index.js +16 -3
- package/dist/migrations/0014_calls_enabled.sql +7 -0
- package/dist/migrations/0015_domain_unique.sql +39 -0
- package/dist/migrations/0016_platform.sql +61 -0
- package/dist/migrations/0017_requested_changes.sql +42 -0
- package/dist/migrations/0018_platform_apply.sql +19 -0
- package/dist/org.d.ts +18 -2
- package/dist/org.js +56 -0
- package/dist/plan/agora.d.ts +77 -0
- package/dist/plan/agora.js +127 -0
- package/dist/plan/calls-matrix.d.ts +135 -0
- package/dist/plan/calls-matrix.js +275 -0
- package/dist/plan/cloudflared-connector.d.ts +70 -0
- package/dist/plan/cloudflared-connector.js +106 -0
- package/dist/plan/diff.d.ts +26 -5
- package/dist/plan/diff.js +720 -106
- package/dist/plan/executor.d.ts +731 -36
- package/dist/plan/executor.js +1180 -41
- package/dist/plan/index.d.ts +22 -5
- package/dist/plan/index.js +12 -2
- package/dist/plan/jobs-scheduler-http.d.ts +29 -0
- package/dist/plan/jobs-scheduler-http.js +50 -0
- package/dist/plan/live.d.ts +51 -2
- package/dist/plan/live.js +8 -0
- package/dist/plan/plan-apply.d.ts +192 -3
- package/dist/plan/plan-apply.js +290 -14
- package/dist/plan/platform-diff.d.ts +312 -0
- package/dist/plan/platform-diff.js +867 -0
- package/dist/plan/platform-org-ports.d.ts +50 -0
- package/dist/plan/platform-org-ports.js +70 -0
- package/dist/plan/platform-org.d.ts +120 -0
- package/dist/plan/platform-org.js +115 -0
- package/dist/plan/platform-providers.d.ts +501 -0
- package/dist/plan/platform-providers.js +3029 -0
- package/dist/plan/platform-sfu.d.ts +93 -0
- package/dist/plan/platform-sfu.js +100 -0
- package/dist/plan/providers-readers.js +22 -1
- package/dist/plan/zitadel-machine-user.d.ts +34 -0
- package/dist/plan/zitadel-machine-user.js +95 -0
- package/dist/plan.d.ts +6 -0
- package/dist/platform.d.ts +55 -0
- package/dist/platform.js +46 -0
- package/dist/requested-changes.d.ts +108 -0
- package/dist/requested-changes.js +95 -0
- package/dist/slug.js +21 -2
- package/dist/store/audit.js +4 -2
- package/dist/store/postgres.d.ts +40 -7
- package/dist/store/postgres.js +257 -29
- package/dist/store/schema.d.ts +700 -0
- package/dist/store/schema.js +58 -0
- package/dist/store.d.ts +56 -0
- package/package.json +2 -2
package/dist/store/schema.js
CHANGED
|
@@ -13,6 +13,7 @@ export const declaredOrgs = pgTable('foundry_declared_orgs', {
|
|
|
13
13
|
mailMode: text('mail_mode').notNull().default('off'),
|
|
14
14
|
mailUsesDomain: boolean('mail_uses_domain').notNull().default(false),
|
|
15
15
|
chatUsesDomain: boolean('chat_uses_domain').notNull().default(false),
|
|
16
|
+
callsEnabled: boolean('calls_enabled').notNull().default(false),
|
|
16
17
|
callsUsesDomain: boolean('calls_uses_domain').notNull().default(false),
|
|
17
18
|
issuerUsesDomain: boolean('issuer_uses_domain').notNull().default(false),
|
|
18
19
|
// SiteConfig (org.ts, T10). A brand new org has no cms site.
|
|
@@ -87,4 +88,61 @@ export const foundryAuditEvents = pgTable('foundry_audit_events', {
|
|
|
87
88
|
outcome: text('outcome').$type(),
|
|
88
89
|
reason: text('reason'),
|
|
89
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'),
|
|
90
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
|
|
@@ -14,6 +16,16 @@ export interface DeclaredOrgStore {
|
|
|
14
16
|
get(id: OrgId): Promise<DeclaredOrg | null>;
|
|
15
17
|
/** Whether any org already holds this slug. `slugFromName` asks it. */
|
|
16
18
|
slugTaken(slug: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* The org id, if any, whose applied state already records `zoneId` under a
|
|
21
|
+
* `cloudflare:zone:*` key (#131). `plan/executor.ts`'s `cloudflareZone`
|
|
22
|
+
* asks this before adopting a zone `findZoneByApex` finds, the same
|
|
23
|
+
* foreign-resource refusal `cloudflareAccess` makes by reading Cloudflare's
|
|
24
|
+
* own Access-app name -- a Cloudflare zone carries no org-identifying
|
|
25
|
+
* field of its own for that live check, so this asks the store's own
|
|
26
|
+
* record instead.
|
|
27
|
+
*/
|
|
28
|
+
findOrgIdForZone(zoneId: string): Promise<OrgId | null>;
|
|
17
29
|
/**
|
|
18
30
|
* Combinations foundry knows are impossible are rejected with a reason
|
|
19
31
|
* (#18 "Done when"), so a caller must be ready for this to throw rather
|
|
@@ -33,3 +45,47 @@ export interface DeclaredOrgStore {
|
|
|
33
45
|
*/
|
|
34
46
|
delete(id: OrgId): Promise<void>;
|
|
35
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.
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@wtfalch/auth": "0.16.0",
|
|
41
41
|
"@wtfalch/email": "0.15.0",
|
|
42
|
-
"@wtfalch/providers": "0.
|
|
42
|
+
"@wtfalch/providers": "0.6.0",
|
|
43
43
|
"ssh2": "1.17.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|