@saplings/sdk 0.0.0-stage → 0.17.2

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 (151) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +60 -2
  4. package/dist/access.d.ts +3 -0
  5. package/dist/access.js +3 -0
  6. package/dist/access.js.map +1 -0
  7. package/dist/accounts.d.ts +3 -0
  8. package/dist/accounts.js +3 -0
  9. package/dist/accounts.js.map +1 -0
  10. package/dist/analytics.d.ts +45 -0
  11. package/dist/analytics.js +129 -0
  12. package/dist/analytics.js.map +1 -0
  13. package/dist/audit.d.ts +21 -0
  14. package/dist/audit.js +36 -0
  15. package/dist/audit.js.map +1 -0
  16. package/dist/automation.d.ts +49 -0
  17. package/dist/automation.js +210 -0
  18. package/dist/automation.js.map +1 -0
  19. package/dist/billing-policy.d.ts +15 -0
  20. package/dist/billing-policy.js +17 -0
  21. package/dist/billing-policy.js.map +1 -0
  22. package/dist/billing.d.ts +53 -0
  23. package/dist/billing.js +118 -0
  24. package/dist/billing.js.map +1 -0
  25. package/dist/business-workflows.d.ts +39 -0
  26. package/dist/business-workflows.js +137 -0
  27. package/dist/business-workflows.js.map +1 -0
  28. package/dist/capabilities.d.ts +49 -0
  29. package/dist/capabilities.js +78 -0
  30. package/dist/capabilities.js.map +1 -0
  31. package/dist/cashfree.d.ts +71 -0
  32. package/dist/cashfree.js +241 -0
  33. package/dist/cashfree.js.map +1 -0
  34. package/dist/commerce.d.ts +21 -0
  35. package/dist/commerce.js +198 -0
  36. package/dist/commerce.js.map +1 -0
  37. package/dist/config.d.ts +4 -0
  38. package/dist/config.js +177 -0
  39. package/dist/config.js.map +1 -0
  40. package/dist/control-plane.d.ts +129 -0
  41. package/dist/control-plane.js +314 -0
  42. package/dist/control-plane.js.map +1 -0
  43. package/dist/data.d.ts +58 -0
  44. package/dist/data.js +214 -0
  45. package/dist/data.js.map +1 -0
  46. package/dist/domain-policy.d.ts +36 -0
  47. package/dist/domain-policy.js +114 -0
  48. package/dist/domain-policy.js.map +1 -0
  49. package/dist/feature-types.d.ts +187 -0
  50. package/dist/feature-types.js +2 -0
  51. package/dist/feature-types.js.map +1 -0
  52. package/dist/federation.d.ts +66 -0
  53. package/dist/federation.js +162 -0
  54. package/dist/federation.js.map +1 -0
  55. package/dist/flags.d.ts +27 -0
  56. package/dist/flags.js +52 -0
  57. package/dist/flags.js.map +1 -0
  58. package/dist/governance.d.ts +45 -0
  59. package/dist/governance.js +128 -0
  60. package/dist/governance.js.map +1 -0
  61. package/dist/http-idempotency.d.ts +22 -0
  62. package/dist/http-idempotency.js +42 -0
  63. package/dist/http-idempotency.js.map +1 -0
  64. package/dist/http.d.ts +2 -0
  65. package/dist/http.js +28 -0
  66. package/dist/http.js.map +1 -0
  67. package/dist/identity.d.ts +3 -0
  68. package/dist/identity.js +3 -0
  69. package/dist/identity.js.map +1 -0
  70. package/dist/impersonation.d.ts +2 -0
  71. package/dist/impersonation.js +3 -0
  72. package/dist/impersonation.js.map +1 -0
  73. package/dist/index.d.ts +210 -0
  74. package/dist/index.js +519 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/integrations.d.ts +114 -0
  77. package/dist/integrations.js +358 -0
  78. package/dist/integrations.js.map +1 -0
  79. package/dist/jobs.d.ts +29 -0
  80. package/dist/jobs.js +77 -0
  81. package/dist/jobs.js.map +1 -0
  82. package/dist/media.d.ts +18 -0
  83. package/dist/media.js +48 -0
  84. package/dist/media.js.map +1 -0
  85. package/dist/offboarding.d.ts +43 -0
  86. package/dist/offboarding.js +140 -0
  87. package/dist/offboarding.js.map +1 -0
  88. package/dist/operations.d.ts +105 -0
  89. package/dist/operations.js +286 -0
  90. package/dist/operations.js.map +1 -0
  91. package/dist/primitives.d.ts +26 -0
  92. package/dist/primitives.js +119 -0
  93. package/dist/primitives.js.map +1 -0
  94. package/dist/provider-operations.d.ts +43 -0
  95. package/dist/provider-operations.js +143 -0
  96. package/dist/provider-operations.js.map +1 -0
  97. package/dist/provider-workflow.d.ts +33 -0
  98. package/dist/provider-workflow.js +111 -0
  99. package/dist/provider-workflow.js.map +1 -0
  100. package/dist/providers.d.ts +42 -0
  101. package/dist/providers.js +168 -0
  102. package/dist/providers.js.map +1 -0
  103. package/dist/quality-config.d.ts +50 -0
  104. package/dist/quality-config.js +2 -0
  105. package/dist/quality-config.js.map +1 -0
  106. package/dist/razorpay-webhook.d.ts +38 -0
  107. package/dist/razorpay-webhook.js +106 -0
  108. package/dist/razorpay-webhook.js.map +1 -0
  109. package/dist/recurring.d.ts +53 -0
  110. package/dist/recurring.js +241 -0
  111. package/dist/recurring.js.map +1 -0
  112. package/dist/registry.d.ts +58 -0
  113. package/dist/registry.js +839 -0
  114. package/dist/registry.js.map +1 -0
  115. package/dist/reliability.d.ts +45 -0
  116. package/dist/reliability.js +147 -0
  117. package/dist/reliability.js.map +1 -0
  118. package/dist/resources.d.ts +19 -0
  119. package/dist/resources.js +90 -0
  120. package/dist/resources.js.map +1 -0
  121. package/dist/security-state.d.ts +14 -0
  122. package/dist/security-state.js +39 -0
  123. package/dist/security-state.js.map +1 -0
  124. package/dist/storage.d.ts +54 -0
  125. package/dist/storage.js +100 -0
  126. package/dist/storage.js.map +1 -0
  127. package/dist/store.d.ts +21 -0
  128. package/dist/store.js +110 -0
  129. package/dist/store.js.map +1 -0
  130. package/dist/stripe-payment.d.ts +21 -0
  131. package/dist/stripe-payment.js +132 -0
  132. package/dist/stripe-payment.js.map +1 -0
  133. package/dist/stripe-recurring.d.ts +58 -0
  134. package/dist/stripe-recurring.js +226 -0
  135. package/dist/stripe-recurring.js.map +1 -0
  136. package/dist/totp.d.ts +2 -0
  137. package/dist/totp.js +3 -0
  138. package/dist/totp.js.map +1 -0
  139. package/dist/transactional-processing.d.ts +27 -0
  140. package/dist/transactional-processing.js +125 -0
  141. package/dist/transactional-processing.js.map +1 -0
  142. package/dist/types.d.ts +367 -0
  143. package/dist/types.js +2 -0
  144. package/dist/types.js.map +1 -0
  145. package/dist/valkey.d.ts +18 -0
  146. package/dist/valkey.js +22 -0
  147. package/dist/valkey.js.map +1 -0
  148. package/dist/worker.d.ts +28 -0
  149. package/dist/worker.js +201 -0
  150. package/dist/worker.js.map +1 -0
  151. package/package.json +34 -3
@@ -0,0 +1,839 @@
1
+ import { BusinessWorkflows } from './business-workflows.js';
2
+ import { KingsmanMembership } from '@saplings/kingsman';
3
+ import { quotePlanChange } from './billing-policy.js';
4
+ import { ProviderWorkflow } from './provider-workflow.js';
5
+ import { GovernanceService } from './governance.js';
6
+ import { DomainPolicyService } from './domain-policy.js';
7
+ import { ProviderOperations } from './provider-operations.js';
8
+ import { ImpersonationService } from './impersonation.js';
9
+ import { Operations } from './operations.js';
10
+ import { Accounts } from './accounts.js';
11
+ import { RecurringBilling } from './recurring.js';
12
+ import { TenantOffboarding } from './offboarding.js';
13
+ import { Commerce } from './commerce.js';
14
+ import { DataService, EnvelopeCrypto, validateRecord } from './data.js';
15
+ import { Analytics } from './analytics.js';
16
+ import { Automation } from './automation.js';
17
+ import { Lifecycle, Metrics, idempotent, } from './reliability.js';
18
+ import { atomic, fail, hash, insert, integer, object, page, read, redact, strings, text, update, } from './primitives.js';
19
+ import { randomUUID } from 'node:crypto';
20
+ const id = (i) => `SAAS-${String(i).padStart(3, '0')}`;
21
+ export class SaasServicesRegistry {
22
+ sdk;
23
+ businessWorkflows;
24
+ providerWorkflows;
25
+ governance;
26
+ domains;
27
+ providerOperations;
28
+ recurring;
29
+ offboarding;
30
+ impersonation;
31
+ operations;
32
+ accounts;
33
+ commerce;
34
+ data;
35
+ analytics;
36
+ automation;
37
+ lifecycle = new Lifecycle();
38
+ metrics = new Metrics();
39
+ bindings = new Map();
40
+ constructor(sdk) {
41
+ this.sdk = sdk;
42
+ const s = sdk.store;
43
+ this.governance = new GovernanceService(s, (c, p) => sdk.access.require(c, p), sdk.config.services?.retentionPolicies);
44
+ this.domains = new DomainPolicyService(s, sdk.config.services?.domainPolicies ?? {});
45
+ this.providerOperations = new ProviderOperations(s, sdk.config.services?.providerOperations ?? {}, 15000, async (c, kind, action) => {
46
+ await sdk.access.requireService(c, `provider-operations:${kind}:${action}`);
47
+ const profile = await s.get(c.tenantId, 'tenant-profile', 'profile');
48
+ if (action === 'submit' && profile && profile.status !== 'active')
49
+ return fail('Tenant is not active', 'TENANT_FROZEN', 403);
50
+ });
51
+ this.providerWorkflows = new ProviderWorkflow(s, this.providerOperations, sdk.config.services?.providerWorkflows ?? {}, (c, name) => sdk.access.require(c, `provider-workflow:${name}:execute`));
52
+ this.recurring = new RecurringBilling(s, sdk.config.services?.recurring);
53
+ this.offboarding = new TenantOffboarding(s, sdk.config.services?.offboarding);
54
+ this.operations = new Operations(sdk, sdk.config.services?.operations);
55
+ this.accounts = new Accounts(s, sdk.config.services?.encryptionKey, sdk.config.services?.accountPasswordPolicy);
56
+ this.impersonation = new ImpersonationService(s, this.accounts, sdk.access, sdk.audit, sdk.config.services?.impersonationScopes);
57
+ this.commerce = new Commerce(s);
58
+ this.businessWorkflows = new BusinessWorkflows(s, sdk.access, sdk.audit);
59
+ this.data = new DataService(s, sdk.config.services?.dataCollections ?? [
60
+ 'organizations',
61
+ 'workspaces',
62
+ 'projects',
63
+ 'teams',
64
+ 'documents',
65
+ 'contacts',
66
+ 'tasks',
67
+ 'feedback',
68
+ ], this.domains, sdk.config.app.environment === 'production');
69
+ this.analytics = new Analytics(s);
70
+ this.automation = new Automation(s);
71
+ this.register();
72
+ }
73
+ register() {
74
+ const sdk = this.sdk, s = sdk.store, a = this.accounts, b = this.commerce, d = this.data, n = this.analytics, w = this.automation;
75
+ const bind = (nums, operations, kind = 'local', note) => {
76
+ for (const i of Array.isArray(nums) ? nums : [nums])
77
+ this.bindings.set(id(i), { kind, operations, note });
78
+ };
79
+ const provider = (nums, actions, note) => {
80
+ for (const i of Array.isArray(nums) ? nums : [nums])
81
+ bind(i, Object.fromEntries(actions.map((action) => [
82
+ action,
83
+ async () => fail(`Configure provider adapter for ${id(i)}:${action}`, 'PROVIDER_REQUIRED', 503),
84
+ ])), 'provider', note);
85
+ };
86
+ const crud = (num, collection, validate = (x) => x) => {
87
+ const check = async (c, action) => {
88
+ await sdk.access.requireService(c, `${collection}:${action === 'get' || action === 'list' ? 'read' : action}`);
89
+ if (sdk.config.app.environment === 'production' && !this.domains.hasPolicy(collection))
90
+ return fail(`Configure explicit domain policy for ${collection}`, 'DOMAIN_POLICY_REQUIRED', 503);
91
+ };
92
+ const domain = this.domains;
93
+ bind(num, {
94
+ create: async (c, i) => {
95
+ await check(c, 'create');
96
+ const data = validate(object(i));
97
+ return domain.hasPolicy(collection)
98
+ ? domain.mutate(c, collection, randomUUID(), 'create', data)
99
+ : insert(s, c, collection, data);
100
+ },
101
+ get: async (c, i) => {
102
+ await check(c, 'get');
103
+ if (domain.hasPolicy(collection))
104
+ return ((await domain.get(c, collection, text(i.id))) ??
105
+ fail('Resource not found', 'NOT_FOUND', 404));
106
+ return read(s, c, collection, i.id);
107
+ },
108
+ list: async (c, i) => {
109
+ await check(c, 'list');
110
+ return domain.hasPolicy(collection)
111
+ ? domain.list(c, collection, {
112
+ limit: i.limit === undefined ? undefined : integer(i.limit, 'limit', 1, 500),
113
+ after: i.after === undefined ? undefined : text(i.after),
114
+ })
115
+ : page(s, c, collection, i);
116
+ },
117
+ update: async (c, i) => {
118
+ await check(c, 'update');
119
+ const changes = validate(object(i.changes), true);
120
+ return domain.hasPolicy(collection)
121
+ ? domain.mutate(c, collection, text(i.id), 'update', changes)
122
+ : update(s, c, collection, i.id, changes);
123
+ },
124
+ delete: async (c, i) => {
125
+ await check(c, 'delete');
126
+ if (domain.hasPolicy(collection))
127
+ return domain.mutate(c, collection, text(i.id), 'delete');
128
+ return atomic(s, c.tenantId, async (tx) => {
129
+ if ((await tx.get(c.tenantId, 'legal-holds', 'current'))?.active === true)
130
+ return fail('Legal hold active', 'LEGAL_HOLD', 409);
131
+ return tx.delete(c.tenantId, collection, text(i.id));
132
+ });
133
+ },
134
+ });
135
+ };
136
+ const resource = (num, r) => bind(num, {
137
+ create: (c, i) => r.create(c, i),
138
+ get: (c, i) => r.get(c, text(i.id)),
139
+ list: (c, i) => r.list(c, i),
140
+ update: (c, i) => r.update(c, text(i.id), object(i.changes)),
141
+ delete: (c, i) => r.delete(c, text(i.id)),
142
+ });
143
+ const issue = (c, i, purpose) => {
144
+ const deliver = sdk.config.services?.challengeDelivery;
145
+ if (deliver)
146
+ return a.requestChallenge(c.tenantId, i.email, purpose, (m) => deliver({ ...m, tenantId: c.tenantId }));
147
+ if (sdk.config.app.environment === 'production')
148
+ return fail('Challenge delivery provider required', 'CONFIG_REQUIRED', 503);
149
+ return a.challenge(c.tenantId, i.email, purpose);
150
+ };
151
+ const required = (...fields) => (x, partial = false) => {
152
+ for (const f of fields)
153
+ if (!partial || Object.hasOwn(x, f))
154
+ text(x[f], f);
155
+ return x;
156
+ };
157
+ bind(1, {
158
+ register: (c, i) => a.register(c.tenantId, { email: i.email, password: i.password }),
159
+ });
160
+ bind(2, {
161
+ issue: (c, i) => issue(c, i, 'passwordless'),
162
+ consume: (c, i) => a.consume(c.tenantId, i.secret, 'passwordless'),
163
+ });
164
+ bind(3, {
165
+ issue: (c, i) => issue(c, i, 'verify'),
166
+ consume: (c, i) => a.consume(c.tenantId, i.secret, 'verify'),
167
+ });
168
+ bind(4, {
169
+ issue: (c, i) => issue(c, i, 'reset'),
170
+ consume: (c, i) => a.consume(c.tenantId, i.secret, 'reset', i.password),
171
+ });
172
+ bind(5, {
173
+ login: (c, i) => a.login(c.tenantId, { email: i.email, password: i.password }),
174
+ logout: (c, i) => a.logout(c, text(i.token)),
175
+ });
176
+ bind(6, {
177
+ verify: (c, i) => a.verify(c.tenantId, text(i.token)),
178
+ list: (c) => a.sessions(c),
179
+ revoke: (c, i) => a.logout(c, text(i.token)),
180
+ });
181
+ bind(7, {
182
+ verify: async (c, i) => {
183
+ const p = sdk.config.providers?.authentication;
184
+ let v;
185
+ if (p)
186
+ v = await p.verifyAccessToken(text(i.token));
187
+ else if (sdk.kingsman)
188
+ v = await sdk.kingsman.verifyAccessToken(text(i.token), {
189
+ audiences: [text(i.audience, 'audience', 100)],
190
+ });
191
+ else
192
+ return fail('Configure Kingsman realm or verified JWT/OIDC adapter', 'PROVIDER_REQUIRED', 503);
193
+ if (!v || v.tenantId !== c.tenantId)
194
+ return fail('Invalid token', 'UNAUTHENTICATED', 401);
195
+ return v;
196
+ },
197
+ }, 'hybrid', 'JWT verification delegated to configured Kingsman realm or authentication adapter; audience required.');
198
+ bind(8, {
199
+ create: (c, i) => sdk.identity.createApiKey(c, {
200
+ name: text(i.name),
201
+ scopes: strings(i.scopes),
202
+ ttlDays: i.ttlDays === undefined ? undefined : integer(i.ttlDays),
203
+ }),
204
+ list: (c) => sdk.identity.listKeys(c),
205
+ revoke: (c, i) => sdk.identity.revokeApiKey(c, text(i.id)),
206
+ });
207
+ bind(9, {
208
+ enroll: (c, i) => a.enrollMfa(c, { password: i.password }),
209
+ confirm: (c, i) => a.confirmMfa(c, i.code),
210
+ challenge: (c, i) => a.login(c.tenantId, { email: i.email, password: i.password }),
211
+ verify: (c, i) => a.verifyMfa(c.tenantId, i.challenge, i.code),
212
+ revoke: (c, i) => a.revokeMfa(c, { token: i.token, code: i.code }),
213
+ }, 'hybrid', 'TOTP with encrypted factor, replay prevention and MFA-gated local sessions; external federation MFA separate.');
214
+ provider(10, ['start', 'callback', 'metadata'], 'SAML federation identity provider.');
215
+ provider(11, ['authorize', 'callback', 'refresh', 'revoke'], 'OAuth2/OIDC provider.');
216
+ provider(12, ['start', 'callback'], 'Social identity provider.');
217
+ bind(13, {
218
+ register: (c, i) => insert(s, c, 'trusted-devices', {
219
+ userId: c.actorId,
220
+ deviceId: text(i.deviceId),
221
+ status: 'pending',
222
+ }),
223
+ revoke: (c, i) => update(s, c, 'trusted-devices', i.id, { status: 'revoked' }),
224
+ }, 'hybrid', 'Device records only; hardware attestation requires provider.');
225
+ bind(14, {
226
+ create: (c, i) => sdk.identity.createApiKey(c, { name: text(i.name), scopes: strings(i.scopes) }),
227
+ revoke: (c, i) => sdk.identity.revokeApiKey(c, text(i.id)),
228
+ });
229
+ bind(15, {
230
+ setRole: (c, i) => sdk.access.setRole(c, text(i.id), strings(i.permissions)),
231
+ check: (c, i) => sdk.access.has(c, text(i.permission), object(i.resource ?? {})),
232
+ assign: async (c, i) => {
233
+ await sdk.access.requireRoleGrant(c, strings(i.roles));
234
+ return a.roles(c, text(i.userId), i.roles);
235
+ },
236
+ });
237
+ bind([16, 17], { check: (c, i) => sdk.access.has(c, text(i.permission), object(i.resource ?? {})) }, 'hybrid', 'Rules registered in trusted application code; policy authoring external.');
238
+ bind(18, { login: (c, i) => a.login(c.tenantId, { email: i.email, password: i.password }) });
239
+ bind(19, {
240
+ provision: (c, i) => atomic(s, c.tenantId, async (tx) => {
241
+ const old = await tx.get(c.tenantId, 'tenant-profile', 'profile');
242
+ if (old)
243
+ return fail('Tenant exists', 'CONFLICT', 409);
244
+ return insert(tx, c, 'tenant-profile', { name: text(i.name), status: 'active', region: text(i.region ?? 'default') }, 'profile');
245
+ }),
246
+ }, 'hybrid', 'Logical provisioning only; infrastructure provisioning delegated.');
247
+ bind([20, 22], {
248
+ context: (c) => ({
249
+ tenantId: c.tenantId,
250
+ actorId: c.actorId,
251
+ correlationId: c.correlationId,
252
+ }),
253
+ });
254
+ bind(21, { check: (c, i) => ({ allowed: c.tenantId === text(i.tenantId) }) }, 'hybrid', 'Tenant-scoped storage; database RLS and app authorization still required.');
255
+ bind(23, { get: (c) => read(s, c, 'tenant-profile', 'profile') }, 'hybrid', 'Physical region routing must be enforced by provider.');
256
+ bind(24, {
257
+ request: (c, i) => this.offboarding.request(c, i),
258
+ approve: (c) => this.offboarding.approve(c),
259
+ status: (c) => this.offboarding.status(c),
260
+ advance: (c) => this.offboarding.advance(c),
261
+ }, 'hybrid', 'Durable, approved offboarding workflow; configure idempotent legal hold, revoke, export, purge and verification handlers.');
262
+ resource(25, sdk.organizations);
263
+ resource(26, sdk.workspaces);
264
+ resource(27, sdk.projects);
265
+ resource(28, sdk.teams);
266
+ resource(29, sdk.memberships);
267
+ bind(30, {
268
+ invite: async (c, i) => {
269
+ await sdk.access.requireRoleGrant(c, strings(i.roles));
270
+ return a.invite(c, i.email, i.roles);
271
+ },
272
+ accept: (c, i) => a.acceptInvite(c, i.secret),
273
+ });
274
+ bind(31, { switch: (c, i) => new KingsmanMembership(s).switchOrganization(c, i.membershipId) });
275
+ bind(32, { set: (c, i) => sdk.access.setRole(c, text(i.id), strings(i.permissions)) });
276
+ bind(33, {
277
+ start: (c, i) => this.impersonation.start(c, i),
278
+ stop: (c, i) => this.impersonation.stop(c, i.token),
279
+ }, 'hybrid', 'Restricted local support sessions with recent MFA and audit; application must use verified context and preserve impersonator ID.');
280
+ bind(34, {
281
+ create: (c, i) => sdk.billing.createPlan(c, {
282
+ name: text(i.name),
283
+ priceMinor: integer(i.priceMinor),
284
+ currency: text(i.currency),
285
+ features: strings(i.features),
286
+ }),
287
+ list: (c, i) => page(s, c, 'plans', i),
288
+ });
289
+ bind(35, {
290
+ create: (c, i) => b.subscribe(c, i),
291
+ list: (c, i) => page(s, c, 'subscriptions', i),
292
+ });
293
+ bind(36, {
294
+ transition: (c, i) => b.transition(c, i.id, i.status),
295
+ schedule: (c, i) => this.recurring.schedule(c, i),
296
+ issueDue: (c, i) => this.recurring.issueDue(c, i.id),
297
+ cancelSchedule: (c, i) => this.recurring.cancel(c, i.id),
298
+ quoteChange: (_c, i) => quotePlanChange({
299
+ oldMinor: integer(i.oldMinor),
300
+ newMinor: integer(i.newMinor),
301
+ periodStart: integer(i.periodStart),
302
+ periodEnd: integer(i.periodEnd),
303
+ effectiveAt: integer(i.effectiveAt),
304
+ taxBps: i.taxBps === undefined ? undefined : integer(i.taxBps, 'taxBps', 0, 10000),
305
+ }),
306
+ }, 'hybrid', 'Fixed-day recurring invoice scheduling; application scheduler and verified payment gateway required; proration quote available; actual plan-change posting and jurisdiction tax rules require application policy.');
307
+ bind(37, {
308
+ start: (c, i) => b.subscribe(c, { ...i, trialDays: integer(i.trialDays, 'trialDays', 1, 365) }),
309
+ });
310
+ bind(38, {
311
+ meter: (c, i) => {
312
+ if (sdk.config.app.environment === 'production' && !i.eventId)
313
+ return fail('Usage event ID required in production', 'IDEMPOTENCY_REQUIRED', 400);
314
+ return sdk.billing.meter(c, text(i.metric), integer(i.quantity ?? 1, 'quantity', 1), String(i.period ?? 'monthly'), i.eventId === undefined ? undefined : text(i.eventId, 'eventId', 200));
315
+ },
316
+ get: (c, i) => sdk.billing.getUsage(c, text(i.metric), String(i.period ?? 'monthly')),
317
+ });
318
+ bind(39, {
319
+ set: (c, i) => sdk.billing.setQuota(c, text(i.metric), integer(i.limit), String(i.period ?? 'monthly')),
320
+ get: (c, i) => sdk.billing.getUsage(c, text(i.metric), String(i.period ?? 'monthly')),
321
+ });
322
+ bind(40, {
323
+ set: (c, i) => {
324
+ if (typeof i.enabled !== 'boolean')
325
+ return fail('enabled must be boolean');
326
+ return sdk.billing.setEntitlement(c, text(i.feature), i.enabled);
327
+ },
328
+ check: (c, i) => sdk.billing.hasEntitlement(c, text(i.feature)),
329
+ });
330
+ bind(41, {
331
+ create: (c, i) => b.invoice(c, i),
332
+ get: (c, i) => read(s, c, 'invoices', i.id),
333
+ list: (c, i) => page(s, c, 'invoices', i),
334
+ });
335
+ bind(42, {
336
+ order: (c, i) => sdk.payments.createOrder(c, {
337
+ amountMinor: integer(i.amountMinor, 'amount', 1),
338
+ currency: text(i.currency),
339
+ reference: text(i.reference),
340
+ invoiceId: i.invoiceId === undefined ? undefined : text(i.invoiceId),
341
+ idempotencyKey: i.idempotencyKey === undefined ? undefined : text(i.idempotencyKey),
342
+ }),
343
+ }, 'hybrid', 'Cashfree preferred; Razorpay or Stripe selectable. Order is not confirmation; use payments.reconcilePayment or verified provider callback.');
344
+ provider(43, ['attach', 'list', 'detach'], 'Provider tokenized payment methods; never store raw cards.');
345
+ bind(44, {
346
+ calculate: (_c, i) => ({
347
+ taxMinor: Number((BigInt(integer(i.netMinor)) * BigInt(integer(i.taxBps, 'taxBps', 0, 10000)) + 5000n) /
348
+ 10000n),
349
+ }),
350
+ }, 'hybrid', 'Supplied rate calculation, not jurisdiction tax determination.');
351
+ bind(45, { create: (c, i) => b.coupon(c, i), redeem: (c, i) => b.redeem(c, i) });
352
+ bind(46, { post: (c, i) => b.wallet(c, i) });
353
+ bind(47, {
354
+ refund: (c, i) => sdk.payments.refund(c, {
355
+ paymentId: text(i.paymentId),
356
+ amountMinor: i.amountMinor === undefined ? undefined : integer(i.amountMinor, 'amount', 1),
357
+ idempotencyKey: text(i.idempotencyKey),
358
+ }),
359
+ }, 'hybrid', 'Cashfree refund reconciliation via payments.reconcileRefund; other providers require verified provider-specific reconciliation.');
360
+ bind(48, {
361
+ enqueue: (c, i) => w.enqueue(c, { type: 'billing.dunning', payload: i, idempotencyKey: i.idempotencyKey }),
362
+ chargeDue: (c, i) => this.recurring.chargeDue(c, i.invoiceId),
363
+ resume: (c, i) => this.recurring.resume(c, i.invoiceId),
364
+ sweep: (c, i) => this.recurring.sweep(c, i),
365
+ }, 'hybrid', 'Durable retry schedule and idempotent recurring gateway; verify provider payment result.');
366
+ bind(49, { report: (c) => b.revenue(c) });
367
+ provider(50, ['verify', 'reconcile'], 'Cashfree signed webhook built in when configured; Razorpay webhook retained; Stripe recurring callback separate.');
368
+ bind(51, {
369
+ scan: (_c, i) => {
370
+ const root = sdk.config.security.scanner.root;
371
+ if (!root)
372
+ return fail('Configure fixed scanner root', 'CONFIG_REQUIRED', 503);
373
+ return sdk.scan(root, i.url === undefined ? undefined : text(i.url));
374
+ },
375
+ });
376
+ bind(52, {
377
+ assess: (c, i) => sdk.defender.assess({
378
+ method: typeof i.method === 'string' ? i.method : undefined,
379
+ url: typeof i.url === 'string' ? i.url : undefined,
380
+ body: i.body,
381
+ tenantId: c.tenantId,
382
+ userId: c.actorId,
383
+ }),
384
+ });
385
+ bind(53, Object.fromEntries(['get', 'put', 'rotate'].map((action) => [
386
+ action,
387
+ (c, i) => this.operations.vault(c, action, i),
388
+ ])), 'hybrid', 'Encrypted local vault; external KMS and key rotation policy required.');
389
+ bind(54, {
390
+ encrypt: (c, i) => this.crypto().encrypt(c, text(i.plain, 'plain', 1000000)),
391
+ decrypt: (c, i) => this.crypto().decrypt(c, i),
392
+ }, 'hybrid', 'Configure encryption key; storage-wide encryption is infrastructure policy.');
393
+ bind(55, {
394
+ verify: (_c, i) => this.operations.tls('verify', i),
395
+ configure: (_c, i) => this.operations.tls('configure', i),
396
+ }, 'hybrid', 'Fixed HTTPS verification and configured certificate control; certificate control plane adapter required for configuration.');
397
+ bind([56, 57, 58, 59, 60, 66, 67], { policy: () => sdk.httpPolicies.edgePolicy(sdk.config.security.defender) }, 'hybrid', 'Enforced by configured runtime middleware; do not expose policy to clients.');
398
+ bind(61, {
399
+ run: (c, i) => sdk.config.app.environment === 'production' || sdk.config.services?.retentionPolicies
400
+ ? this.governance.sweep(c, text(i.collection), {
401
+ after: i.after === undefined ? undefined : text(i.after),
402
+ limit: i.limit === undefined ? undefined : integer(i.limit, 'limit', 1, 500),
403
+ confirm: i.confirm === true,
404
+ })
405
+ : d.retention(c, i),
406
+ });
407
+ bind(62, { delete: (c, i) => d.remove(c, i) });
408
+ bind(63, {
409
+ record: (c, i) => d.consent(c, i),
410
+ history: (c, i) => page(s, c, 'consent-history', i),
411
+ });
412
+ bind(64, {
413
+ export: (c, i) => sdk.exportTenantData(c, i.collections === undefined ? undefined : strings(i.collections)),
414
+ });
415
+ bind(65, {
416
+ list: (c, i) => sdk.audit.list(c, integer(i.limit ?? 100, 'limit', 1, 500)),
417
+ record: (c, i) => sdk.audit.record(c, text(i.action), text(i.resourceType), i.resourceId === undefined ? undefined : text(i.resourceId), object(redact(i.detail ?? {}))),
418
+ });
419
+ bind(68, {
420
+ list: (c, i) => page(s, c, 'security-incidents', i),
421
+ ack: (c, i) => update(s, c, 'security-incidents', i.id, { status: 'acknowledged', ackBy: c.actorId }),
422
+ });
423
+ crud(69, 'vulnerabilities', required('title', 'severity'));
424
+ crud(70, 'compliance-evidence', required('control', 'evidenceRef'));
425
+ for (const [num, channel] of [
426
+ [71, 'email'],
427
+ [73, 'sms'],
428
+ [74, 'push'],
429
+ ])
430
+ bind(num, { send: (c, i) => this.notify(c, channel, i) }, 'hybrid', `${channel} delivery provider required.`);
431
+ bind(72, {
432
+ enqueue: (c, i) => {
433
+ const recipients = strings(i.recipients);
434
+ if (recipients.length > 500)
435
+ return fail('Max 500 recipients');
436
+ return w.enqueue(c, {
437
+ type: 'notifications.bulk',
438
+ payload: { ...i, recipients },
439
+ idempotencyKey: i.idempotencyKey,
440
+ });
441
+ },
442
+ }, 'hybrid', 'Worker must register bulk delivery handler.');
443
+ bind(75, {
444
+ send: (c, i) => insert(s, c, 'inapp-notifications', { to: text(i.to), body: text(i.body), read: false }),
445
+ list: async (c, i) => {
446
+ const p = await page(s, c, 'inapp-notifications', i);
447
+ return { ...p, items: p.items.filter((r) => r.to === c.actorId) };
448
+ },
449
+ read: async (c, i) => {
450
+ const r = await read(s, c, 'inapp-notifications', i.id);
451
+ if (r.to !== c.actorId)
452
+ return fail('Not recipient', 'FORBIDDEN', 403);
453
+ return update(s, c, 'inapp-notifications', r.id, { read: true });
454
+ },
455
+ });
456
+ crud(76, 'notification-templates', required('name', 'body'));
457
+ bind(77, {
458
+ set: (c, i) => this.preference(c, i),
459
+ get: (c, i) => read(s, c, 'notification-preferences', hash(`${c.actorId}:${text(i.channel)}`)),
460
+ });
461
+ bind(78, { list: (c, i) => page(s, c, 'notification-deliveries', i) });
462
+ bind(79, {
463
+ enqueue: (c, i) => w.enqueue(c, {
464
+ type: 'notification.retry',
465
+ payload: i,
466
+ idempotencyKey: i.idempotencyKey,
467
+ }),
468
+ }, 'hybrid', 'Register delivery handler.');
469
+ bind(80, { optOut: (c, i) => this.preference(c, { ...i, enabled: false }) });
470
+ bind(81, {
471
+ verify: (c, i) => this.operations.webhook(c, 'verify', i, true),
472
+ reconcile: (c, i) => this.operations.webhook(c, 'reconcile', i, true),
473
+ }, 'hybrid', 'Signed Sapling callback envelope; vendor-specific adapters can override.');
474
+ bind(82, {
475
+ render: async (c, i) => {
476
+ const r = await read(s, c, 'notification-templates', i.id);
477
+ const translations = object(r.translations ?? {});
478
+ const lang = text(i.locale);
479
+ return {
480
+ body: this.render(typeof translations[lang] === 'string' ? String(translations[lang]) : String(r.body), object(i.variables ?? {})),
481
+ };
482
+ },
483
+ });
484
+ bind([83, 84], {
485
+ upload: (c, i) => sdk.storage.upload(c, {
486
+ key: text(i.key),
487
+ data: Buffer.from(text(i.base64, 'base64', 15000000), 'base64'),
488
+ metadata: i.metadata,
489
+ }),
490
+ download: (c, i) => sdk.storage.download(c, text(i.key), i.version === undefined ? undefined : text(i.version)),
491
+ list: (c, i) => sdk.storage.list(c, String(i.prefix ?? '')),
492
+ delete: (c, i) => sdk.storage.delete(c, text(i.key)),
493
+ }, 'hybrid', 'Storage adapter required in production.');
494
+ provider(85, ['sign'], 'Presigned URL provider; use tenant-scoped object key.');
495
+ bind(86, {
496
+ get: async (c, i) => {
497
+ const r = await sdk.storage.download(c, text(i.key));
498
+ return r
499
+ ? { metadata: r.metadata, version: r.version, bytes: r.data.byteLength }
500
+ : undefined;
501
+ },
502
+ });
503
+ bind(87, { get: (c, i) => sdk.storage.download(c, text(i.key), text(i.version)) });
504
+ crud(88, 'documents', required('title', 'objectKey'));
505
+ bind(89, { import: (c, i) => d.import(c, i) });
506
+ bind(90, { export: (c, i) => d.export(c, i) });
507
+ bind(91, Object.fromEntries(['backup', 'restore', 'status'].map((action) => [
508
+ action,
509
+ (c, i) => this.operations.backup(c, action, i),
510
+ ])), 'hybrid', 'Bounded encrypted tenant logical backup; physical DB and object-store backup still external.');
511
+ provider(92, ['plan', 'apply', 'status'], 'Migration runner executes reviewed migrations outside requests.');
512
+ bind(93, { search: (c, i) => d.search(c, i) }, 'hybrid', 'Bounded cursor-based search and optional database search; dedicated full-text index for scale.');
513
+ provider(94, ['purge', 'configure'], 'CDN provider.');
514
+ provider(95, ['transform', 'status'], 'Media processing worker.');
515
+ bind(96, { validate: (_c, i) => validateRecord(object(i.data), object(i.schema)) });
516
+ bind(97, { delete: (c, i) => d.softDelete(c, i) });
517
+ bind(98, { archive: (c, i) => d.archive(c, i) });
518
+ bind(99, { mask: (_c, i) => redact(i.data) });
519
+ bind(100, { track: (c, i) => n.track(c, i) });
520
+ bind(101, { identify: (c, i) => n.identify(c, i) });
521
+ bind(102, { report: (c, i) => n.count(c, { ...i, by: 'groupId' }) });
522
+ bind(103, { report: (c, i) => n.funnel(c, i) });
523
+ bind(104, { report: (c, i) => n.retention(c, i) });
524
+ bind(105, { report: (c, i) => n.cohort(c, i) });
525
+ crud(106, 'dashboards', required('name'));
526
+ bind(107, { report: (c, i) => n.count(c, i) });
527
+ bind(108, {
528
+ schedule: (c, i) => w.enqueue(c, {
529
+ type: 'report.generate',
530
+ payload: i,
531
+ dueAt: i.dueAt,
532
+ idempotencyKey: i.idempotencyKey,
533
+ }),
534
+ }, 'hybrid', 'Register report worker.');
535
+ bind(109, { report: (c, i) => n.metric(c, i) });
536
+ bind(110, {
537
+ capture: (c, i) => n.track(c, { name: 'error', properties: object(redact(i)), subjectId: c.actorId }),
538
+ report: (c, i) => n.count(c, { ...i, name: 'error' }),
539
+ });
540
+ bind(111, { report: (c, i) => n.experiment(c, i) });
541
+ bind(112, { report: (c, i) => n.count(c, i) });
542
+ bind([113, 114], {
543
+ enqueue: async (c, i) => {
544
+ const type = text(i.type, 'job type', 100);
545
+ if (!w.registered(type))
546
+ return fail('Job type not registered', 'UNKNOWN_ACTION', 404);
547
+ await sdk.access.requireService(c, `jobs:enqueue:${type}`);
548
+ return w.enqueue(c, i);
549
+ },
550
+ list: (c, i) => page(s, c, 'durable-jobs', i),
551
+ });
552
+ bind(115, { requeue: (c, i) => w.requeue(c, i.id) });
553
+ bind(116, {
554
+ list: async (c, i) => ({
555
+ items: (await page(s, c, 'durable-jobs', i)).items.filter((r) => r.status === 'dead'),
556
+ }),
557
+ requeue: (c, i) => w.requeue(c, i.id),
558
+ });
559
+ bind(117, {
560
+ start: async (c, i) => {
561
+ await sdk.access.requireService(c, `workflows:execute:${text(i.workflow, 'workflow', 100)}`);
562
+ return w.enqueue(c, {
563
+ type: 'workflow.execute',
564
+ payload: i,
565
+ idempotencyKey: i.idempotencyKey,
566
+ });
567
+ },
568
+ }, 'hybrid', 'Workflow worker required; no arbitrary code evaluation.');
569
+ bind(118, { request: (c, i) => w.approval(c, i), decide: (c, i) => w.decide(c, i) });
570
+ bind(119, { evaluate: (c, i) => w.rule(c, i) });
571
+ bind(120, {
572
+ enqueue: async (c, i) => {
573
+ await sdk.access.requireService(c, `events:dispatch:${text(i.type, 'event type', 100)}`);
574
+ return w.enqueue(c, {
575
+ type: 'event.dispatch',
576
+ payload: i,
577
+ idempotencyKey: i.idempotencyKey,
578
+ });
579
+ },
580
+ }, 'hybrid', 'Register event worker.');
581
+ bind(121, {
582
+ verify: (c, i) => this.operations.webhook(c, 'verify', i),
583
+ dispatch: (c, i) => this.operations.webhook(c, 'dispatch', i),
584
+ }, 'hybrid', 'Timestamp signature, replay inbox and atomic outbox; configure trusted secrets.');
585
+ bind(122, {
586
+ record: (c, i) => idempotent(s, c, text(i.key), object(i.data), async (tx) => insert(tx, c, 'idempotent-records', object(i.data))),
587
+ });
588
+ bind(123, {
589
+ append: async (c, i) => {
590
+ await sdk.access.requireService(c, `events:dispatch:${text(i.type, 'event type', 100)}`);
591
+ return w.outbox(c, i);
592
+ },
593
+ }, 'hybrid', 'Atomic local append; delivery relay must be configured.');
594
+ bind(124, { envelope: (c, i) => sdk.httpPolicies.envelope(c, i) });
595
+ bind(125, {
596
+ execute: (c, i) => this.operations.graphql(c, 'execute', i),
597
+ schema: (c, i) => this.operations.graphql(c, 'schema', i),
598
+ }, 'hybrid', 'Application supplies vetted GraphQL executor and schema.');
599
+ bind(126, { document: () => this.operations.openapi() }, 'hybrid', 'Provide application OpenAPI document in unified config.');
600
+ bind(127, { generate: () => this.operations.generateClient() }, 'local', 'Generates TypeScript fetch client from configured OpenAPI operations; not schema-typed.');
601
+ bind(128, { resolve: (_c, i) => sdk.httpPolicies.resolveVersion(i) });
602
+ bind(129, {
603
+ page: (c, i) => {
604
+ const collection = d.collection(i.collection);
605
+ return this.domains.hasPolicy(collection)
606
+ ? this.domains.list(c, collection, {
607
+ limit: i.limit === undefined ? undefined : integer(i.limit, 'limit', 1, 500),
608
+ after: i.after === undefined ? undefined : text(i.after),
609
+ })
610
+ : page(s, c, collection, i);
611
+ },
612
+ });
613
+ bind(130, {
614
+ filter: async (c, i) => {
615
+ const collection = d.collection(i.collection), f = object(i.filter);
616
+ if (this.domains.hasPolicy(collection) &&
617
+ Object.keys(f).some((k) => !this.domains.readable(collection, k)))
618
+ return fail('Filter field not readable', 'FORBIDDEN', 403);
619
+ const r = this.domains.hasPolicy(collection)
620
+ ? await this.domains.list(c, collection, {
621
+ limit: i.limit === undefined ? undefined : integer(i.limit, 'limit', 1, 500),
622
+ after: i.after === undefined ? undefined : text(i.after),
623
+ })
624
+ : await page(s, c, collection, i);
625
+ return {
626
+ ...r,
627
+ items: r.items.filter((x) => Object.entries(f).every(([k, v]) => x[k] === v)),
628
+ };
629
+ },
630
+ });
631
+ bind(131, { headers: (_c, i) => sdk.httpPolicies.rateLimitHeaders(i) });
632
+ crud(132, 'developer-apps', required('name'));
633
+ bind(133, { check: async (c, i) => ({ allowed: await sdk.access.has(c, text(i.scope)) }) });
634
+ bind(134, {
635
+ sign: (_c, i) => sdk.webhooks.sign(text(i.payload, 'payload', 1000000), text(i.secret)),
636
+ verify: (_c, i) => sdk.webhooks.verify(text(i.payload, 'payload', 1000000), text(i.secret), integer(i.timestamp), text(i.signature)),
637
+ });
638
+ bind(135, {
639
+ enqueue: async (c, i) => {
640
+ await sdk.access.requireService(c, `webhooks:deliver:${text(i.destination, 'destination', 100)}`);
641
+ return w.enqueue(c, {
642
+ type: 'webhook.deliver',
643
+ payload: i,
644
+ idempotencyKey: i.idempotencyKey,
645
+ });
646
+ },
647
+ }, 'hybrid', 'Configure outbound destinations and signed delivery worker.');
648
+ bind(136, { emit: (c, i) => sdk.events.emit(c, text(i.type), object(i.data)) }, 'hybrid', 'Local event bus; durable broker external.');
649
+ bind(137, { get: (c) => sdk.httpPolicies.correlation(c) });
650
+ bind(138, { envelope: (c, i) => sdk.httpPolicies.errorEnvelope(c, i) });
651
+ bind([139, 140, 141], {
652
+ set: (c, i) => sdk.flags.set(c, {
653
+ key: text(i.key),
654
+ enabled: i.enabled === true,
655
+ rollout: i.rollout === undefined ? undefined : integer(i.rollout, 'rollout', 0, 100),
656
+ variants: i.variants,
657
+ }),
658
+ evaluate: (c, i) => sdk.flags.evaluate(c, text(i.key), i.subjectId === undefined ? undefined : text(i.subjectId)),
659
+ });
660
+ bind(142, { get: () => ({ environment: sdk.config.app.environment, app: sdk.config.app.id }) });
661
+ for (const [num, collection] of [
662
+ [143, 'tenant-settings'],
663
+ [144, 'remote-config'],
664
+ [147, 'white-label'],
665
+ [151, 'themes'],
666
+ [152, 'branding'],
667
+ [153, 'maintenance-settings'],
668
+ ])
669
+ crud(num, collection);
670
+ bind(145, Object.fromEntries(['install', 'uninstall', 'list'].map((action) => [
671
+ action,
672
+ (c, i) => this.operations.plugins(c, action, i),
673
+ ])), 'hybrid', 'Trusted catalog activation metadata; plugin runtime is application registered.');
674
+ crud(146, 'integration-settings', required('name'));
675
+ bind(148, Object.fromEntries(['request', 'verify', 'activate', 'remove'].map((action) => [
676
+ action,
677
+ (c, i) => this.operations.domains(c, action, i),
678
+ ])), 'hybrid', 'DNS TXT challenge and verified activation/removal through configured routing/TLS control plane.');
679
+ bind(149, {
680
+ format: (_c, i) => new Intl.NumberFormat(text(i.locale), i.options).format(Number(i.value)),
681
+ });
682
+ bind(150, {
683
+ format: (_c, i) => new Intl.DateTimeFormat(text(i.locale ?? 'en'), {
684
+ timeZone: text(i.timeZone),
685
+ dateStyle: 'medium',
686
+ timeStyle: 'short',
687
+ }).format(new Date(text(i.date))),
688
+ });
689
+ bind(154, {
690
+ log: (_c, i) => sdk.telemetry.log('info', text(i.event), object(redact(i.fields ?? {}))),
691
+ });
692
+ provider(155, ['export', 'status'], 'OpenTelemetry tracing provider.');
693
+ bind(156, {
694
+ observe: (_c, i) => {
695
+ this.metrics.observe(integer(i.status, 'status', 100, 599), integer(i.ms));
696
+ return this.metrics.snapshot();
697
+ },
698
+ snapshot: () => this.metrics.snapshot(),
699
+ });
700
+ bind(157, { get: () => sdk.health() });
701
+ bind(158, { get: () => sdk.readiness() });
702
+ bind([159, 160, 161, 162], {
703
+ describe: () => ({
704
+ available: 'Use exported CircuitBreaker, retry, timeout, Bulkhead around trusted service functions',
705
+ }),
706
+ }, 'local', 'Executable typed utilities exported; do not expose callbacks over HTTP.');
707
+ bind(163, { report: () => this.metrics.snapshot() });
708
+ bind(164, {
709
+ record: (c, i) => insert(s, c, 'operational-alerts', {
710
+ message: text(i.message),
711
+ severity: text(i.severity),
712
+ status: 'open',
713
+ }),
714
+ list: (c, i) => page(s, c, 'operational-alerts', i),
715
+ }, 'hybrid', 'Alert routing external.');
716
+ provider(165, ['deploy', 'status', 'rollback'], 'CI/CD control plane.');
717
+ provider(166, ['plan', 'apply', 'destroy'], 'Infrastructure provisioning control plane.');
718
+ provider(167, ['scale', 'status'], 'Kubernetes autoscaler/control plane.');
719
+ provider(168, ['backup', 'restore', 'drill'], 'Disaster recovery provider and operational drills.');
720
+ bind(169, { status: () => ({ acceptingWork: this.lifecycle.ready }) }, 'local', 'Lifecycle.close() explicitly called by application shutdown hook.');
721
+ bind(170, { validate: () => ({ valid: true, app: sdk.config.app.id }) });
722
+ crud(171, 'comments', required('resourceId', 'body'));
723
+ resource(172, sdk.activity);
724
+ bind(173, {
725
+ create: (c, i) => this.businessWorkflows.task(c, 'create', i),
726
+ assign: (c, i) => this.businessWorkflows.task(c, 'assign', i),
727
+ complete: (c, i) => this.businessWorkflows.task(c, 'complete', i),
728
+ list: async (c, i) => {
729
+ const result = await page(s, c, 'tasks', i);
730
+ const elevated = await sdk.access.has(c, 'tasks:manage');
731
+ return {
732
+ ...result,
733
+ items: result.items.filter((r) => elevated || r.creatorId === c.actorId || r.assigneeId === c.actorId),
734
+ };
735
+ },
736
+ });
737
+ bind(174, {
738
+ list: async (c, i) => {
739
+ await sdk.access.require(c, 'approvals:read');
740
+ return page(s, c, 'approval-history', i);
741
+ },
742
+ });
743
+ crud(175, 'resource-shares', required('resourceId', 'granteeId'));
744
+ crud(176, 'contacts', required('name'));
745
+ bind(177, { list: (c) => a.directory(c) });
746
+ bind(178, {
747
+ create: (c, i) => this.businessWorkflows.ticket(c, 'create', i),
748
+ update: (c, i) => this.businessWorkflows.ticket(c, 'update', i),
749
+ list: async (c, i) => {
750
+ const result = await page(s, c, 'tickets', i);
751
+ const elevated = await sdk.access.has(c, 'tickets:manage');
752
+ return {
753
+ ...result,
754
+ items: result.items.filter((r) => elevated || r.requester === c.actorId),
755
+ };
756
+ },
757
+ });
758
+ crud(179, 'feedback', required('body'));
759
+ bind(180, {
760
+ overview: async (c) => {
761
+ await sdk.access.require(c, 'admin:overview');
762
+ return {
763
+ tenantId: c.tenantId,
764
+ hasProjects: (await page(s, c, 'projects', { limit: 1 })).items.length > 0,
765
+ health: sdk.health(),
766
+ };
767
+ },
768
+ }, 'hybrid', 'Backend overview; admin UI not part of backend SDK.');
769
+ crud(181, 'usage-policies', required('name'));
770
+ bind(182, { transfer: (c, i) => this.businessWorkflows.transfer(c, i) }, 'hybrid', 'App must validate target ownership and resource-specific permissions.');
771
+ }
772
+ crypto() {
773
+ const key = this.sdk.config.services?.encryptionKey;
774
+ if (!key)
775
+ return fail('Encryption key required', 'PROVIDER_REQUIRED', 503);
776
+ return new EnvelopeCrypto(key);
777
+ }
778
+ render(template, variables) {
779
+ return template.replace(/\{\{([A-Za-z0-9_]+)\}\}/g, (_, key) => String(variables[key] ?? ''));
780
+ }
781
+ async preference(c, i) {
782
+ const channel = text(i.channel);
783
+ if (!['email', 'sms', 'push', 'inapp'].includes(channel) || typeof i.enabled !== 'boolean')
784
+ return fail('Invalid preference');
785
+ const r = {
786
+ id: hash(`${c.actorId}:${channel}`),
787
+ userId: c.actorId,
788
+ channel,
789
+ enabled: i.enabled,
790
+ };
791
+ await this.sdk.store.put(c.tenantId, 'notification-preferences', r);
792
+ return r;
793
+ }
794
+ async notify(c, channel, i) {
795
+ const to = text(i.to);
796
+ const subjectId = text(i.subjectId, 'subjectId');
797
+ const pref = await this.sdk.store.get(c.tenantId, 'notification-preferences', hash(`${subjectId}:${channel}`));
798
+ if (pref?.enabled === false)
799
+ return { status: 'suppressed' };
800
+ const result = await this.sdk.notifications.send(c, {
801
+ channel,
802
+ to,
803
+ body: text(i.body, 'body', 100000),
804
+ subject: i.subject === undefined ? undefined : text(i.subject),
805
+ });
806
+ await insert(this.sdk.store, c, 'notification-deliveries', {
807
+ providerId: result.id,
808
+ channel,
809
+ subjectId,
810
+ status: result.status,
811
+ });
812
+ return result;
813
+ }
814
+ get(featureId) {
815
+ return this.bindings.get(featureId);
816
+ }
817
+ adapters() {
818
+ return Object.fromEntries([...this.bindings].map(([featureId, b]) => [
819
+ featureId,
820
+ {
821
+ execute: async ({ ctx, action, input }) => {
822
+ const operation = b.operations[action];
823
+ if (!operation || !Object.hasOwn(b.operations, action))
824
+ return fail('Unknown action', 'UNKNOWN_ACTION', 404);
825
+ return operation(ctx, input);
826
+ },
827
+ },
828
+ ]));
829
+ }
830
+ manifest() {
831
+ return [...this.bindings].map(([featureId, b]) => ({
832
+ featureId,
833
+ kind: b.kind,
834
+ actions: Object.keys(b.operations),
835
+ note: b.note,
836
+ }));
837
+ }
838
+ }
839
+ //# sourceMappingURL=registry.js.map