openxiangda-nest 2.0.0-alpha.100

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 (106) hide show
  1. package/README.md +158 -0
  2. package/dist/application-credentials.d.ts +19 -0
  3. package/dist/application-credentials.d.ts.map +1 -0
  4. package/dist/application-credentials.js +158 -0
  5. package/dist/application-credentials.js.map +1 -0
  6. package/dist/assignee-provider.d.ts +35 -0
  7. package/dist/assignee-provider.d.ts.map +1 -0
  8. package/dist/assignee-provider.js +223 -0
  9. package/dist/assignee-provider.js.map +1 -0
  10. package/dist/authz.d.ts +28 -0
  11. package/dist/authz.d.ts.map +1 -0
  12. package/dist/authz.js +207 -0
  13. package/dist/authz.js.map +1 -0
  14. package/dist/bootstrap.d.ts +15 -0
  15. package/dist/bootstrap.d.ts.map +1 -0
  16. package/dist/bootstrap.js +40 -0
  17. package/dist/bootstrap.js.map +1 -0
  18. package/dist/business-action-context.d.ts +14 -0
  19. package/dist/business-action-context.d.ts.map +1 -0
  20. package/dist/business-action-context.js +41 -0
  21. package/dist/business-action-context.js.map +1 -0
  22. package/dist/business-directory.d.ts +14 -0
  23. package/dist/business-directory.d.ts.map +1 -0
  24. package/dist/business-directory.js +40 -0
  25. package/dist/business-directory.js.map +1 -0
  26. package/dist/business-notification.d.ts +23 -0
  27. package/dist/business-notification.d.ts.map +1 -0
  28. package/dist/business-notification.js +58 -0
  29. package/dist/business-notification.js.map +1 -0
  30. package/dist/business-process.d.ts +23 -0
  31. package/dist/business-process.d.ts.map +1 -0
  32. package/dist/business-process.js +106 -0
  33. package/dist/business-process.js.map +1 -0
  34. package/dist/data-api.d.ts +116 -0
  35. package/dist/data-api.d.ts.map +1 -0
  36. package/dist/data-api.js +248 -0
  37. package/dist/data-api.js.map +1 -0
  38. package/dist/event-context.d.ts +15 -0
  39. package/dist/event-context.d.ts.map +1 -0
  40. package/dist/event-context.js +33 -0
  41. package/dist/event-context.js.map +1 -0
  42. package/dist/event-handler.d.ts +36 -0
  43. package/dist/event-handler.d.ts.map +1 -0
  44. package/dist/event-handler.js +174 -0
  45. package/dist/event-handler.js.map +1 -0
  46. package/dist/events.d.ts +64 -0
  47. package/dist/events.d.ts.map +1 -0
  48. package/dist/events.js +513 -0
  49. package/dist/events.js.map +1 -0
  50. package/dist/gateway-transport.d.ts +53 -0
  51. package/dist/gateway-transport.d.ts.map +1 -0
  52. package/dist/gateway-transport.js +369 -0
  53. package/dist/gateway-transport.js.map +1 -0
  54. package/dist/health.d.ts +36 -0
  55. package/dist/health.d.ts.map +1 -0
  56. package/dist/health.js +105 -0
  57. package/dist/health.js.map +1 -0
  58. package/dist/index.d.ts +25 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +25 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/infrastructure-controller.d.ts +8 -0
  63. package/dist/infrastructure-controller.d.ts.map +1 -0
  64. package/dist/infrastructure-controller.js +15 -0
  65. package/dist/infrastructure-controller.js.map +1 -0
  66. package/dist/logger.d.ts +20 -0
  67. package/dist/logger.d.ts.map +1 -0
  68. package/dist/logger.js +62 -0
  69. package/dist/logger.js.map +1 -0
  70. package/dist/module.d.ts +6 -0
  71. package/dist/module.d.ts.map +1 -0
  72. package/dist/module.js +293 -0
  73. package/dist/module.js.map +1 -0
  74. package/dist/notification.d.ts +18 -0
  75. package/dist/notification.d.ts.map +1 -0
  76. package/dist/notification.js +52 -0
  77. package/dist/notification.js.map +1 -0
  78. package/dist/platform-client.d.ts +115 -0
  79. package/dist/platform-client.d.ts.map +1 -0
  80. package/dist/platform-client.js +506 -0
  81. package/dist/platform-client.js.map +1 -0
  82. package/dist/runtime.d.ts +56 -0
  83. package/dist/runtime.d.ts.map +1 -0
  84. package/dist/runtime.js +253 -0
  85. package/dist/runtime.js.map +1 -0
  86. package/dist/standard-operations.d.ts +62 -0
  87. package/dist/standard-operations.d.ts.map +1 -0
  88. package/dist/standard-operations.js +169 -0
  89. package/dist/standard-operations.js.map +1 -0
  90. package/dist/todo.d.ts +20 -0
  91. package/dist/todo.d.ts.map +1 -0
  92. package/dist/todo.js +48 -0
  93. package/dist/todo.js.map +1 -0
  94. package/dist/tokens.d.ts +5 -0
  95. package/dist/tokens.d.ts.map +1 -0
  96. package/dist/tokens.js +5 -0
  97. package/dist/tokens.js.map +1 -0
  98. package/dist/types.d.ts +178 -0
  99. package/dist/types.d.ts.map +1 -0
  100. package/dist/types.js +2 -0
  101. package/dist/types.js.map +1 -0
  102. package/dist/workflow.d.ts +41 -0
  103. package/dist/workflow.d.ts.map +1 -0
  104. package/dist/workflow.js +97 -0
  105. package/dist/workflow.js.map +1 -0
  106. package/package.json +64 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authz.d.ts","sourceRoot":"","sources":["../src/authz.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAOjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAEL,+BAA+B,EAChC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAEV,sBAAsB,EAEtB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,qFACM,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,uBAAuB,IAEnE,QAAQ,MAAM,EACd,cAAc,MAAM,GAAG,MAAM,EAC7B,aAAa,uBAAuB,CAAC,GAAG,CAAC,UAgB5C;AAED,eAAO,MAAM,gBAAgB,mDAQ5B,CAAC;AAEF,eAAO,MAAM,WAAW,mDAGvB,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,0BAA0B,GACnC,sBAAsB,CAiBxB;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,eAAe,EAC1B,SAAS,CAAC,EAAE,MAAM,EAAE,GACnB,sBAAsB,CAaxB;AAED,eAAO,MAAM,kBAAkB,mDAG9B,CAAC;AAEF,eAAO,MAAM,2BAA2B,mDAUvC,CAAC;AAEF,eAAO,MAAM,yBAAyB,mDAGrC,CAAC;AAEF,qBACa,qBAAsB,YAAW,WAAW;IAGrD,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAGjC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAwF9D,OAAO,CAAC,mBAAmB;IAmB3B,OAAO,CAAC,gBAAgB;CAgCzB"}
package/dist/authz.js ADDED
@@ -0,0 +1,207 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { ForbiddenException, Inject, Injectable, SetMetadata, UnauthorizedException, createParamDecorator, } from "@nestjs/common";
14
+ import { Reflector } from "@nestjs/core";
15
+ import { SCHEMA_VERSIONS } from "openxiangda-contracts";
16
+ import { isOpenXiangdaInfrastructureController } from "./infrastructure-controller.js";
17
+ import { OPENXIANGDA_OPERATION_CONTRACT, OPENXIANGDA_REQUIRED_CAPABILITY, } from "./tokens.js";
18
+ export const RequireCapability = (capability) => SetMetadata(OPENXIANGDA_REQUIRED_CAPABILITY, capability);
19
+ /**
20
+ * Binds one controller route to the immutable App API contract and protects it
21
+ * with the same generated capability constant. The release verifier can inspect
22
+ * this metadata without bootstrapping application business code.
23
+ */
24
+ export function OpenXiangdaOperation(operation) {
25
+ return (target, propertyKey, descriptor) => {
26
+ SetMetadata(OPENXIANGDA_OPERATION_CONTRACT, operation)(target, propertyKey, descriptor);
27
+ SetMetadata(OPENXIANGDA_REQUIRED_CAPABILITY, operation.requiredCapability)(target, propertyKey, descriptor);
28
+ };
29
+ }
30
+ export const CurrentPrincipal = createParamDecorator((_data, context) => {
31
+ const principal = requireContext(context).principal;
32
+ if (principal.principalType !== "user") {
33
+ throw new UnauthorizedException("OPENXIANGDA_USER_PRINCIPAL_REQUIRED");
34
+ }
35
+ return principal;
36
+ });
37
+ export const CurrentUser = createParamDecorator((_data, context) => currentUserFromVerifiedContext(requireContext(context)));
38
+ export function currentUserFromVerifiedContext(verified) {
39
+ const principal = verified.principal;
40
+ if (principal.principalType === "developer") {
41
+ return {
42
+ userId: principal.userId,
43
+ displayName: principal.displayName,
44
+ appCode: principal.appCode,
45
+ environmentKey: principal.environmentKey,
46
+ roleCodes: [...principal.roleCodes],
47
+ isAppSuperAdmin: principal.isAppSuperAdmin,
48
+ capabilityCodes: [...principal.capabilityCodes],
49
+ };
50
+ }
51
+ if (principal.principalType !== "user") {
52
+ throw new UnauthorizedException("OPENXIANGDA_USER_PRINCIPAL_REQUIRED");
53
+ }
54
+ return currentUserFromPrincipal(principal, verified.roleCodes);
55
+ }
56
+ export function currentUserFromPrincipal(principal, roleCodes) {
57
+ const verifiedRoleCodes = roleCodes ||
58
+ principal.roleCodes || [];
59
+ return {
60
+ userId: principal.userId,
61
+ displayName: principal.displayName,
62
+ appCode: principal.appCode,
63
+ environmentKey: principal.environmentKey,
64
+ roleCodes: [...new Set(verifiedRoleCodes)],
65
+ isAppSuperAdmin: principal.isAppSuperAdmin,
66
+ capabilityCodes: [...principal.capabilities],
67
+ };
68
+ }
69
+ export const CurrentPerspective = createParamDecorator((_data, context) => requireContext(context).perspectiveCode);
70
+ export const CurrentApplicationPrincipal = createParamDecorator((_data, context) => {
71
+ const principal = requireContext(context).principal;
72
+ if (principal.principalType !== "service") {
73
+ throw new UnauthorizedException("OPENXIANGDA_APPLICATION_PRINCIPAL_REQUIRED");
74
+ }
75
+ return principal;
76
+ });
77
+ export const CurrentOpenXiangdaContext = createParamDecorator((_data, context) => requireContext(context));
78
+ let OpenXiangdaAuthzGuard = class OpenXiangdaAuthzGuard {
79
+ reflector;
80
+ constructor(reflector) {
81
+ this.reflector = reflector;
82
+ }
83
+ async canActivate(context) {
84
+ if (context.getType() !== "http")
85
+ return true;
86
+ if (isOpenXiangdaInfrastructureController(context.getClass()))
87
+ return true;
88
+ const request = context.switchToHttp().getRequest();
89
+ const operation = this.reflector.getAllAndOverride(OPENXIANGDA_OPERATION_CONTRACT, [context.getHandler(), context.getClass()]);
90
+ if (request.openxiangda?.principal.principalType === "developer") {
91
+ // The platform current endpoint has validated the short-lived Dev Session
92
+ // and returned the complete role/capability union. Data operations remain
93
+ // platform-authorized through the same session.
94
+ const capability = this.reflector.getAllAndOverride(OPENXIANGDA_REQUIRED_CAPABILITY, [context.getHandler(), context.getClass()]);
95
+ if (capability &&
96
+ !request.openxiangda.principal.isAppSuperAdmin &&
97
+ !request.openxiangda.principal.capabilityCodes.includes(capability)) {
98
+ throw new ForbiddenException({
99
+ code: "OPENXIANGDA_CAPABILITY_DENIED",
100
+ capability,
101
+ });
102
+ }
103
+ if (operation)
104
+ request.openxiangda.operation = operation;
105
+ return true;
106
+ }
107
+ const invocation = request.openxiangdaInvocation;
108
+ if (!invocation) {
109
+ throw new UnauthorizedException("OPENXIANGDA_GATEWAY_CONTEXT_REQUIRED");
110
+ }
111
+ const { authorization, perspectiveCode } = invocation;
112
+ const capability = this.reflector.getAllAndOverride(OPENXIANGDA_REQUIRED_CAPABILITY, [context.getHandler(), context.getClass()]);
113
+ if (invocation.principal.principalType === "application") {
114
+ const application = invocation.principal;
115
+ if (!application.scopes.includes("app:invoke")) {
116
+ throw new ForbiddenException({
117
+ code: "OPENXIANGDA_APPLICATION_INVOKE_DENIED",
118
+ });
119
+ }
120
+ if (!capability) {
121
+ throw new ForbiddenException({
122
+ code: "OPENXIANGDA_SERVICE_CAPABILITY_REQUIRED",
123
+ });
124
+ }
125
+ if (!application.scopes.includes(capability)) {
126
+ throw new ForbiddenException({
127
+ code: "OPENXIANGDA_CAPABILITY_DENIED",
128
+ capability,
129
+ });
130
+ }
131
+ request.openxiangda = {
132
+ principal: this.servicePrincipal(application, invocation.target),
133
+ authorization,
134
+ perspectiveCode: null,
135
+ ...(operation ? { operation } : {}),
136
+ };
137
+ return true;
138
+ }
139
+ if (this.isVerifiedRoleUnion(invocation.principal)) {
140
+ const roleCodes = [...new Set(invocation.principal.roleCodes)];
141
+ request.openxiangda = {
142
+ principal: invocation.principal,
143
+ authorization,
144
+ perspectiveCode,
145
+ roleCodes,
146
+ ...(operation ? { operation } : {}),
147
+ };
148
+ if (capability &&
149
+ !invocation.principal.isAppSuperAdmin &&
150
+ !invocation.principal.capabilities.includes(capability)) {
151
+ throw new ForbiddenException({
152
+ code: "OPENXIANGDA_CAPABILITY_DENIED",
153
+ capability,
154
+ });
155
+ }
156
+ return true;
157
+ }
158
+ throw new UnauthorizedException("OPENXIANGDA_USER_UNION_REQUIRED");
159
+ }
160
+ isVerifiedRoleUnion(principal) {
161
+ return ((principal.subjectKind === "role_union" ||
162
+ principal.subjectKind === "super_admin") &&
163
+ Array.isArray(principal.roleCodes) &&
164
+ principal.roleCodes.length <= 32 &&
165
+ principal.roleCodes.every(code => /^[A-Za-z0-9._:-]{1,128}$/.test(code)) &&
166
+ Array.isArray(principal.capabilities) &&
167
+ principal.capabilities.length <= 2000 &&
168
+ principal.capabilities.every(code => /^[A-Za-z0-9*._:-]{1,256}$/.test(code)));
169
+ }
170
+ servicePrincipal(input, target) {
171
+ return {
172
+ schemaVersion: SCHEMA_VERSIONS.principal,
173
+ tenantId: input.tenantId,
174
+ appCode: input.appCode,
175
+ environmentKey: input.environmentKey,
176
+ environmentId: target.environmentId,
177
+ appVersionId: target.appVersionId,
178
+ deploymentRunId: target.deploymentRunId,
179
+ environmentHeadRevision: target.headRevision,
180
+ backendRevisionId: target.backendRevisionId,
181
+ principalType: "service",
182
+ subjectId: input.clientId,
183
+ clientRecordId: input.clientRecordId,
184
+ clientId: input.clientId,
185
+ credentialVersion: input.credentialVersion,
186
+ scopes: input.scopes,
187
+ rateLimitPerMinute: input.rateLimitPerMinute,
188
+ tokenId: input.tokenId,
189
+ authzVersion: input.credentialVersion,
190
+ isAppSuperAdmin: false,
191
+ };
192
+ }
193
+ };
194
+ OpenXiangdaAuthzGuard = __decorate([
195
+ Injectable(),
196
+ __param(0, Inject(Reflector)),
197
+ __metadata("design:paramtypes", [Reflector])
198
+ ], OpenXiangdaAuthzGuard);
199
+ export { OpenXiangdaAuthzGuard };
200
+ function requireContext(context) {
201
+ const request = context.switchToHttp().getRequest();
202
+ if (!request.openxiangda) {
203
+ throw new UnauthorizedException("OPENXIANGDA_CONTEXT_NOT_VERIFIED");
204
+ }
205
+ return request.openxiangda;
206
+ }
207
+ //# sourceMappingURL=authz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authz.js","sourceRoot":"","sources":["../src/authz.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAGL,kBAAkB,EAClB,MAAM,EACN,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AACvF,OAAO,EACL,8BAA8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,SAAS,cAAc,CAAC,OAAyB;IAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAA0B,CAAC;IAC5E,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,MAAM,IAAI,qBAAqB,CAAC,kCAAkC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Type } from '@nestjs/common';
2
+ import { type NestFastifyApplication } from '@nestjs/platform-fastify';
3
+ export interface OpenXiangdaApplicationBootstrapOptions {
4
+ port?: number;
5
+ host?: string;
6
+ trustProxy?: boolean;
7
+ }
8
+ /**
9
+ * Starts the canonical OpenXiangda 2.0 NestJS runtime.
10
+ *
11
+ * Raw body capture is part of the gateway assertion contract, so applications
12
+ * must not reproduce the NestFactory/Fastify setup themselves.
13
+ */
14
+ export declare function bootstrapOpenXiangdaApplication(rootModule: Type<unknown>, options?: OpenXiangdaApplicationBootstrapOptions): Promise<NestFastifyApplication>;
15
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,sCAAsC;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAyBD;;;;;GAKG;AACH,wBAAsB,+BAA+B,CACnD,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,EACzB,OAAO,GAAE,sCAA2C,GACnD,OAAO,CAAC,sBAAsB,CAAC,CA0BjC"}
@@ -0,0 +1,40 @@
1
+ import { NestFactory } from '@nestjs/core';
2
+ import { FastifyAdapter, } from '@nestjs/platform-fastify';
3
+ const STRUCTURED_CLOUD_EVENT_CONTENT_TYPE = 'application/cloudevents+json';
4
+ const STRUCTURED_CLOUD_EVENT_BODY_LIMIT = 65_536;
5
+ class OpenXiangdaFastifyAdapter extends FastifyAdapter {
6
+ registerParserMiddleware(prefix, rawBody) {
7
+ super.registerParserMiddleware(prefix, rawBody);
8
+ const fastify = this.getInstance();
9
+ const { onProtoPoisoning, onConstructorPoisoning } = fastify.initialConfig;
10
+ const jsonParser = fastify.getDefaultJsonParser(onProtoPoisoning ?? 'error', onConstructorPoisoning ?? 'error');
11
+ this.useBodyParser(STRUCTURED_CLOUD_EVENT_CONTENT_TYPE, rawBody === true, { bodyLimit: STRUCTURED_CLOUD_EVENT_BODY_LIMIT }, (request, body, done) => jsonParser(request, body.toString('utf8'), done));
12
+ }
13
+ }
14
+ /**
15
+ * Starts the canonical OpenXiangda 2.0 NestJS runtime.
16
+ *
17
+ * Raw body capture is part of the gateway assertion contract, so applications
18
+ * must not reproduce the NestFactory/Fastify setup themselves.
19
+ */
20
+ export async function bootstrapOpenXiangdaApplication(rootModule, options = {}) {
21
+ if (!options || typeof options !== 'object' || Array.isArray(options)) {
22
+ throw new Error('OPENXIANGDA_BOOTSTRAP_OPTIONS_OBJECT_REQUIRED');
23
+ }
24
+ const allowedOptionKeys = new Set(['port', 'host', 'trustProxy']);
25
+ const unknownOption = Object.keys(options).find(key => !allowedOptionKeys.has(key));
26
+ if (unknownOption) {
27
+ throw new Error(`OPENXIANGDA_BOOTSTRAP_OPTION_UNKNOWN:${unknownOption}`);
28
+ }
29
+ const app = await NestFactory.create(rootModule, new OpenXiangdaFastifyAdapter({
30
+ trustProxy: options.trustProxy ?? true,
31
+ }), { rawBody: true });
32
+ app.enableShutdownHooks();
33
+ const production = process.env.NODE_ENV === 'production';
34
+ const port = options.port ??
35
+ Number(process.env.OPENXIANGDA_APP_PORT || process.env.PORT || 3000);
36
+ const host = options.host ?? (production ? '0.0.0.0' : '127.0.0.1');
37
+ await app.listen(port, host);
38
+ return app;
39
+ }
40
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,cAAc,GAEf,MAAM,0BAA0B,CAAC;AAQlC,MAAM,mCAAmC,GAAG,8BAA8B,CAAC;AAC3E,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAEjD,MAAM,yBAA0B,SAAQ,cAAc;IAC3C,wBAAwB,CAAC,MAAe,EAAE,OAAiB;QAClE,KAAK,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEhD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3E,MAAM,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAC7C,gBAAgB,IAAI,OAAO,EAC3B,sBAAsB,IAAI,OAAO,CAClC,CAAC;QACF,IAAI,CAAC,aAAa,CAChB,mCAAmC,EACnC,OAAO,KAAK,IAAI,EAChB,EAAE,SAAS,EAAE,iCAAiC,EAAE,EAChD,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CACtB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CACnD,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,UAAyB,EACzB,UAAkD,EAAE;IAEpD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAC7C,GAAG,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CACnC,CAAC;IACF,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,wCAAwC,aAAa,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,MAAM,CAClC,UAAU,EACV,IAAI,yBAAyB,CAAC;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI;KACvC,CAAC,EACF,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;IACF,GAAG,CAAC,mBAAmB,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IACzD,MAAM,IAAI,GACR,OAAO,CAAC,IAAI;QACZ,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { OpenXiangdaBusinessActionContext, OpenXiangdaHttpRequest } from './types.js';
2
+ export interface OpenXiangdaBusinessActionRuntimeContext {
3
+ authorization: string;
4
+ perspectiveCode: string | null;
5
+ action: OpenXiangdaBusinessActionContext;
6
+ }
7
+ /**
8
+ * Resolves immutable Named Action metadata from the verified request.
9
+ *
10
+ * The authorization value is the short-lived platform invocation (or bounded
11
+ * Connected Dev Session), never the caller's original login token.
12
+ */
13
+ export declare function requireOpenXiangdaBusinessActionContext(request: OpenXiangdaHttpRequest): OpenXiangdaBusinessActionRuntimeContext;
14
+ //# sourceMappingURL=business-action-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-action-context.d.ts","sourceRoot":"","sources":["../src/business-action-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gCAAgC,EAChC,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uCAAuC;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,gCAAgC,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,EAAE,sBAAsB,GAC9B,uCAAuC,CAyCzC"}
@@ -0,0 +1,41 @@
1
+ import { UnauthorizedException } from '@nestjs/common';
2
+ /**
3
+ * Resolves immutable Named Action metadata from the verified request.
4
+ *
5
+ * The authorization value is the short-lived platform invocation (or bounded
6
+ * Connected Dev Session), never the caller's original login token.
7
+ */
8
+ export function requireOpenXiangdaBusinessActionContext(request) {
9
+ const verified = request.openxiangda;
10
+ if (!verified) {
11
+ throw new UnauthorizedException('OPENXIANGDA_CONTEXT_NOT_VERIFIED');
12
+ }
13
+ if (!verified.operation) {
14
+ throw new UnauthorizedException('OPENXIANGDA_BUSINESS_ACTION_OPERATION_REQUIRED');
15
+ }
16
+ if (verified.principal.principalType !== 'user' &&
17
+ verified.principal.principalType !== 'developer') {
18
+ throw new UnauthorizedException('OPENXIANGDA_BUSINESS_ACTION_USER_CONTEXT_REQUIRED');
19
+ }
20
+ return {
21
+ authorization: verified.authorization,
22
+ perspectiveCode: verified.perspectiveCode,
23
+ action: {
24
+ code: verified.operation.code,
25
+ requiredCapability: verified.operation.requiredCapability,
26
+ ...(() => {
27
+ const value = request.headers['x-request-id'];
28
+ const requestId = String(Array.isArray(value) ? value[0] || '' : value || '').trim();
29
+ return /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(requestId)
30
+ ? { requestId }
31
+ : {};
32
+ })(),
33
+ ...(verified.connectedDevelopmentSessionToken
34
+ ? {
35
+ connectedDevelopmentSessionToken: verified.connectedDevelopmentSessionToken,
36
+ }
37
+ : {}),
38
+ },
39
+ };
40
+ }
41
+ //# sourceMappingURL=business-action-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-action-context.js","sourceRoot":"","sources":["../src/business-action-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAYvD;;;;;GAKG;AACH,MAAM,UAAU,uCAAuC,CACrD,OAA+B;IAE/B,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;IACrC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,qBAAqB,CAAC,kCAAkC,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,qBAAqB,CAC7B,gDAAgD,CACjD,CAAC;IACJ,CAAC;IACD,IACE,QAAQ,CAAC,SAAS,CAAC,aAAa,KAAK,MAAM;QAC3C,QAAQ,CAAC,SAAS,CAAC,aAAa,KAAK,WAAW,EAChD,CAAC;QACD,MAAM,IAAI,qBAAqB,CAC7B,mDAAmD,CACpD,CAAC;IACJ,CAAC;IACD,OAAO;QACL,aAAa,EAAE,QAAQ,CAAC,aAAa;QACrC,eAAe,EAAE,QAAQ,CAAC,eAAe;QACzC,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI;YAC7B,kBAAkB,EAAE,QAAQ,CAAC,SAAS,CAAC,kBAAkB;YACzD,GAAG,CAAC,GAAG,EAAE;gBACP,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAC9C,MAAM,SAAS,GAAG,MAAM,CACtB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CACpD,CAAC,IAAI,EAAE,CAAC;gBACT,OAAO,qCAAqC,CAAC,IAAI,CAAC,SAAS,CAAC;oBAC1D,CAAC,CAAC,EAAE,SAAS,EAAE;oBACf,CAAC,CAAC,EAAE,CAAC;YACT,CAAC,CAAC,EAAE;YACJ,GAAG,CAAC,QAAQ,CAAC,gCAAgC;gBAC3C,CAAC,CAAC;oBACE,gCAAgC,EAC9B,QAAQ,CAAC,gCAAgC;iBAC5C;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { CurrentInitiatorDirectorySnapshot } from 'openxiangda-contracts';
2
+ import { OpenXiangdaPlatformClient } from './platform-client.js';
3
+ import type { OpenXiangdaHttpRequest } from './types.js';
4
+ /**
5
+ * Request-scoped access to directory facts declared by the active Named Action.
6
+ * The initiator is always derived from the verified gateway invocation.
7
+ */
8
+ export declare class OpenXiangdaBusinessDirectoryService {
9
+ private readonly request;
10
+ private readonly platform;
11
+ constructor(request: OpenXiangdaHttpRequest, platform: OpenXiangdaPlatformClient);
12
+ currentInitiator(): Promise<CurrentInitiatorDirectorySnapshot>;
13
+ }
14
+ //# sourceMappingURL=business-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-directory.d.ts","sourceRoot":"","sources":["../src/business-directory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;;GAGG;AACH,qBACa,mCAAmC;IAE3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAEzC,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAFS,OAAO,EAAE,sBAAsB,EAEhD,QAAQ,EAAE,yBAAyB;IAGhD,gBAAgB,IAAI,OAAO,CAAC,iCAAiC,CAAC;CAOrE"}
@@ -0,0 +1,40 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable, Scope } from '@nestjs/common';
14
+ import { REQUEST } from '@nestjs/core';
15
+ import { requireOpenXiangdaBusinessActionContext } from './business-action-context.js';
16
+ import { OpenXiangdaPlatformClient } from './platform-client.js';
17
+ /**
18
+ * Request-scoped access to directory facts declared by the active Named Action.
19
+ * The initiator is always derived from the verified gateway invocation.
20
+ */
21
+ let OpenXiangdaBusinessDirectoryService = class OpenXiangdaBusinessDirectoryService {
22
+ request;
23
+ platform;
24
+ constructor(request, platform) {
25
+ this.request = request;
26
+ this.platform = platform;
27
+ }
28
+ async currentInitiator() {
29
+ const context = requireOpenXiangdaBusinessActionContext(this.request);
30
+ return await this.platform.resolveCurrentInitiator(context.authorization, context.action);
31
+ }
32
+ };
33
+ OpenXiangdaBusinessDirectoryService = __decorate([
34
+ Injectable({ scope: Scope.REQUEST }),
35
+ __param(0, Inject(REQUEST)),
36
+ __param(1, Inject(OpenXiangdaPlatformClient)),
37
+ __metadata("design:paramtypes", [Object, OpenXiangdaPlatformClient])
38
+ ], OpenXiangdaBusinessDirectoryService);
39
+ export { OpenXiangdaBusinessDirectoryService };
40
+ //# sourceMappingURL=business-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-directory.js","sourceRoot":"","sources":["../src/business-directory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,uCAAuC,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;;GAGG;AAEI,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAEV;IAEjB;IAHnB,YACoC,OAA+B,EAEhD,QAAmC;QAFlB,YAAO,GAAP,OAAO,CAAwB;QAEhD,aAAQ,GAAR,QAAQ,CAA2B;IACnD,CAAC;IAEJ,KAAK,CAAC,gBAAgB;QACpB,MAAM,OAAO,GAAG,uCAAuC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAChD,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,MAAM,CACf,CAAC;IACJ,CAAC;CACF,CAAA;AAdY,mCAAmC;IAD/C,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAGhC,WAAA,MAAM,CAAC,OAAO,CAAC,CAAA;IACf,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;6CACP,yBAAyB;GAJ3C,mCAAmC,CAc/C"}
@@ -0,0 +1,23 @@
1
+ import type { BusinessNotificationSendV2, EventBusinessNotificationSendV2 } from 'openxiangda-contracts';
2
+ import { OpenXiangdaApplicationCredentials } from './application-credentials.js';
3
+ import { OpenXiangdaEventContext } from './event-context.js';
4
+ import { OpenXiangdaPlatformClient } from './platform-client.js';
5
+ import type { OpenXiangdaHttpRequest } from './types.js';
6
+ export type OpenXiangdaBusinessNotificationInput = Omit<BusinessNotificationSendV2, 'environmentKey'>;
7
+ export type OpenXiangdaEventBusinessNotificationInput = Omit<EventBusinessNotificationSendV2, 'environmentKey'>;
8
+ /**
9
+ * Channel-neutral Notification Hub facade for an authorized Named Action.
10
+ *
11
+ * The platform revalidates the action proof and promotes the call to the exact
12
+ * app/environment application principal while retaining the initiator audit.
13
+ */
14
+ export declare class OpenXiangdaBusinessNotificationService {
15
+ private readonly request;
16
+ private readonly platform;
17
+ private readonly credentials;
18
+ private readonly eventContext;
19
+ constructor(request: OpenXiangdaHttpRequest, platform: OpenXiangdaPlatformClient, credentials: OpenXiangdaApplicationCredentials, eventContext: OpenXiangdaEventContext);
20
+ send(input: OpenXiangdaBusinessNotificationInput): Promise<import("openxiangda-contracts").NotificationMessageV2>;
21
+ sendFromEvent(input: OpenXiangdaEventBusinessNotificationInput): Promise<import("openxiangda-contracts").NotificationMessageV2>;
22
+ }
23
+ //# sourceMappingURL=business-notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-notification.d.ts","sourceRoot":"","sources":["../src/business-notification.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,+BAA+B,EAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,oCAAoC,GAAG,IAAI,CACrD,0BAA0B,EAC1B,gBAAgB,CACjB,CAAC;AACF,MAAM,MAAM,yCAAyC,GAAG,IAAI,CAC1D,+BAA+B,EAC/B,gBAAgB,CACjB,CAAC;AAEF;;;;;GAKG;AACH,qBACa,sCAAsC;IAE9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAEzC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAEzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAE5B,OAAO,CAAC,QAAQ,CAAC,YAAY;gBANK,OAAO,EAAE,sBAAsB,EAEhD,QAAQ,EAAE,yBAAyB,EAEnC,WAAW,EAAE,iCAAiC,EAE9C,YAAY,EAAE,uBAAuB;IAGlD,IAAI,CAAC,KAAK,EAAE,oCAAoC;IAShD,aAAa,CAAC,KAAK,EAAE,yCAAyC;CAUrE"}
@@ -0,0 +1,58 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable, Scope, UnauthorizedException } from '@nestjs/common';
14
+ import { REQUEST } from '@nestjs/core';
15
+ import { OpenXiangdaApplicationCredentials } from './application-credentials.js';
16
+ import { requireOpenXiangdaBusinessActionContext } from './business-action-context.js';
17
+ import { OpenXiangdaEventContext } from './event-context.js';
18
+ import { OpenXiangdaPlatformClient } from './platform-client.js';
19
+ /**
20
+ * Channel-neutral Notification Hub facade for an authorized Named Action.
21
+ *
22
+ * The platform revalidates the action proof and promotes the call to the exact
23
+ * app/environment application principal while retaining the initiator audit.
24
+ */
25
+ let OpenXiangdaBusinessNotificationService = class OpenXiangdaBusinessNotificationService {
26
+ request;
27
+ platform;
28
+ credentials;
29
+ eventContext;
30
+ constructor(request, platform, credentials, eventContext) {
31
+ this.request = request;
32
+ this.platform = platform;
33
+ this.credentials = credentials;
34
+ this.eventContext = eventContext;
35
+ }
36
+ async send(input) {
37
+ const context = requireOpenXiangdaBusinessActionContext(this.request);
38
+ return await this.platform.sendBusinessNotification(context.authorization, input, context.action);
39
+ }
40
+ async sendFromEvent(input) {
41
+ if (!this.eventContext.current()) {
42
+ throw new UnauthorizedException('OPENXIANGDA_BUSINESS_NOTIFICATION_EVENT_CONTEXT_REQUIRED');
43
+ }
44
+ return await this.credentials.withAuthorization(async (authorization) => await this.platform.sendEventNotification(authorization, input));
45
+ }
46
+ };
47
+ OpenXiangdaBusinessNotificationService = __decorate([
48
+ Injectable({ scope: Scope.REQUEST }),
49
+ __param(0, Inject(REQUEST)),
50
+ __param(1, Inject(OpenXiangdaPlatformClient)),
51
+ __param(2, Inject(OpenXiangdaApplicationCredentials)),
52
+ __param(3, Inject(OpenXiangdaEventContext)),
53
+ __metadata("design:paramtypes", [Object, OpenXiangdaPlatformClient,
54
+ OpenXiangdaApplicationCredentials,
55
+ OpenXiangdaEventContext])
56
+ ], OpenXiangdaBusinessNotificationService);
57
+ export { OpenXiangdaBusinessNotificationService };
58
+ //# sourceMappingURL=business-notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-notification.js","sourceRoot":"","sources":["../src/business-notification.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,qBA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AE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAGhC,WAAA,MAAM,CAAC,OAAO,CAAC,CAAA;IACf,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAEjC,WAAA,MAAM,CAAC,iCAAiC,CAAC,CAAA;IAEzC,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;6CAHL,yBAAyB;QAEtB,iCAAiC;QAEhC,uBAAuB;GAR7C,sCAAsC,CA8BlD"}
@@ -0,0 +1,23 @@
1
+ import { type BusinessProcessAnswer, type BusinessProcessCommand, type BusinessProcessCommit, type BusinessProcessPoll, type BusinessProcessReceipt, type BusinessProcessRetry, type ProcessCommandSurface } from 'openxiangda-contracts';
2
+ import { OpenXiangdaPlatformClient } from './platform-client.js';
3
+ import type { OpenXiangdaHttpRequest } from './types.js';
4
+ export type OpenXiangdaBusinessProcessCommitInput = Omit<BusinessProcessCommit, 'schemaVersion' | 'environmentKey'>;
5
+ /**
6
+ * Durable business mutation + Workflow command facade for verified Named Actions.
7
+ * The operation proof is derived exclusively from the gateway-verified request.
8
+ */
9
+ export declare class OpenXiangdaBusinessProcessService {
10
+ private readonly request;
11
+ private readonly platform;
12
+ constructor(request: OpenXiangdaHttpRequest, platform: OpenXiangdaPlatformClient);
13
+ commit(input: OpenXiangdaBusinessProcessCommitInput): Promise<BusinessProcessCommand>;
14
+ status(commandId: string): Promise<BusinessProcessCommand>;
15
+ receipt(commandId: string): Promise<BusinessProcessReceipt>;
16
+ poll(commandId: string, afterRevision?: number): Promise<BusinessProcessPoll>;
17
+ surface(commandId: string): Promise<ProcessCommandSurface>;
18
+ answer(commandId: string, input: Omit<BusinessProcessAnswer, 'schemaVersion'>): Promise<BusinessProcessCommand>;
19
+ retry(commandId: string, input: Omit<BusinessProcessRetry, 'schemaVersion'>): Promise<BusinessProcessCommand>;
20
+ private context;
21
+ private assertDeclared;
22
+ }
23
+ //# sourceMappingURL=business-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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