@stripe/extensibility-custom-objects 0.7.4

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 (48) hide show
  1. package/LICENSE.md +19 -0
  2. package/README.md +63 -0
  3. package/dist/decorators/action.d.ts +29 -0
  4. package/dist/decorators/action.d.ts.map +1 -0
  5. package/dist/decorators/custom-fields.d.ts +16 -0
  6. package/dist/decorators/custom-fields.d.ts.map +1 -0
  7. package/dist/decorators/custom-object.d.ts +19 -0
  8. package/dist/decorators/custom-object.d.ts.map +1 -0
  9. package/dist/decorators/index.d.ts +14 -0
  10. package/dist/decorators/index.d.ts.map +1 -0
  11. package/dist/extensibility-custom-objects-alpha.d.ts +245 -0
  12. package/dist/extensibility-custom-objects-beta.d.ts +245 -0
  13. package/dist/extensibility-custom-objects-internal.d.ts +680 -0
  14. package/dist/extensibility-custom-objects-public.d.ts +245 -0
  15. package/dist/index.cjs +761 -0
  16. package/dist/index.d.ts +26 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +710 -0
  19. package/dist/runtime/base-object.d.ts +84 -0
  20. package/dist/runtime/base-object.d.ts.map +1 -0
  21. package/dist/runtime/deep-clone.d.ts +16 -0
  22. package/dist/runtime/deep-clone.d.ts.map +1 -0
  23. package/dist/runtime/events.d.ts +161 -0
  24. package/dist/runtime/events.d.ts.map +1 -0
  25. package/dist/runtime/flush-helpers.d.ts +9 -0
  26. package/dist/runtime/flush-helpers.d.ts.map +1 -0
  27. package/dist/runtime/invoke.d.ts +19 -0
  28. package/dist/runtime/invoke.d.ts.map +1 -0
  29. package/dist/runtime/persist.d.ts +44 -0
  30. package/dist/runtime/persist.d.ts.map +1 -0
  31. package/dist/runtime/proxy/constants.d.ts +5 -0
  32. package/dist/runtime/proxy/constants.d.ts.map +1 -0
  33. package/dist/runtime/proxy/fields-proxy.d.ts +19 -0
  34. package/dist/runtime/proxy/fields-proxy.d.ts.map +1 -0
  35. package/dist/runtime/proxy/index.d.ts +5 -0
  36. package/dist/runtime/proxy/index.d.ts.map +1 -0
  37. package/dist/runtime/proxy/instance-proxy.d.ts +81 -0
  38. package/dist/runtime/proxy/instance-proxy.d.ts.map +1 -0
  39. package/dist/runtime/proxy/types.d.ts +25 -0
  40. package/dist/runtime/proxy/types.d.ts.map +1 -0
  41. package/dist/runtime/registry.d.ts +40 -0
  42. package/dist/runtime/registry.d.ts.map +1 -0
  43. package/dist/runtime/symbol-helpers.d.ts +17 -0
  44. package/dist/runtime/symbol-helpers.d.ts.map +1 -0
  45. package/dist/runtime/types.d.ts +139 -0
  46. package/dist/runtime/types.d.ts.map +1 -0
  47. package/dist/tsconfig.build.tsbuildinfo +1 -0
  48. package/package.json +48 -0
@@ -0,0 +1,84 @@
1
+ import { type SaveResult } from './types.js';
2
+ /**
3
+ * Abstract base class for all custom objects.
4
+ *
5
+ * Provides built-in platform fields (id, object, created, updated, livemode)
6
+ * and a typed `fields` container for user-defined fields. The generic parameter
7
+ * `T` describes the shape of user fields accessible via `this.fields`.
8
+ *
9
+ * @remarks
10
+ * **Definite assignment assertions (`!`)**: All platform fields (`id`, `object`,
11
+ * `created`, `updated`, `livemode`, `fields`) use the TypeScript definite assignment
12
+ * assertion operator. This suppresses the "property has no initializer" error because
13
+ * these fields are intentionally left unset by the zero-argument constructor.
14
+ *
15
+ * The runtime (`executeInstanceMethod` in `invoke.ts`) is solely responsible for
16
+ * populating these fields via `Object.assign` and `hydrateInstance` **before** the
17
+ * dirty-tracking proxy is installed. Code that constructs a subclass directly
18
+ * (bypassing the runtime) will have `undefined` values for all platform fields at
19
+ * runtime, despite the types suggesting otherwise.
20
+ *
21
+ * @typeParam T - Shape of user-defined fields stored in `fields`
22
+ * @public
23
+ */
24
+ export declare abstract class BaseObject<T extends Record<string, unknown> = Record<string, unknown>> {
25
+ /** Unique identifier assigned by the platform */
26
+ readonly id: string;
27
+ /** Object type identifier assigned by the platform */
28
+ readonly object: string;
29
+ /** Timestamp when the object was created */
30
+ readonly created: Date;
31
+ /** Timestamp when the object was last updated */
32
+ readonly updated: Date;
33
+ /** Whether the object exists in live mode (true) or test mode (false). @public */
34
+ readonly livemode: boolean;
35
+ /**
36
+ * User-defined fields container. Populated during hydration via Object.assign
37
+ * before the dirty-tracking proxy is installed.
38
+ * Access individual fields as `this.fields.fieldName`.
39
+ *
40
+ * @remarks
41
+ * The generic type `T` describes the shape of available fields after
42
+ * hydration, not at construction time. Fields may be undefined before
43
+ * the instance is hydrated with data from the platform.
44
+ *
45
+ * @public
46
+ */
47
+ readonly fields: T;
48
+ /**
49
+ * Flushes pending field mutations into the slated-updates accumulator.
50
+ *
51
+ * When called from a transformed action (no save handler configured), this
52
+ * records which fields were mutated so that the Logic wrapper can include them
53
+ * in the response envelope's `updatedFields`. No network call is made.
54
+ *
55
+ * When a save handler is configured (runtime invoke path), the handler is
56
+ * called for actual persistence and its result is returned.
57
+ *
58
+ * @returns The save result including `updatedFieldCount` (unique fields flushed)
59
+ * @throws Error if the object is not proxied
60
+ * @public
61
+ */
62
+ save(): Promise<SaveResult>;
63
+ /**
64
+ * Discard all pending changes and restore field values to their
65
+ * last-saved state. Has no effect if the object is not proxied.
66
+ *
67
+ * @public
68
+ */
69
+ revert(): void;
70
+ }
71
+ /**
72
+ * Fields that are not tracked for changes by the proxy.
73
+ * These are system-managed fields that should not appear in pendingUpdates.
74
+ *
75
+ * @internal
76
+ */
77
+ export declare const _UNTRACKED_FIELDS: Set<string>;
78
+ /**
79
+ * Checks if a field should be tracked for changes.
80
+ *
81
+ * @internal
82
+ */
83
+ export declare function _isTrackedField(field: string): boolean;
84
+ //# sourceMappingURL=base-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-object.d.ts","sourceRoot":"","sources":["../../src/runtime/base-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAMvF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BAAsB,UAAU,CAE9B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE3D,iDAAiD;IACjD,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAG,MAAM,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAG,IAAI,CAAC;IACxB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAG,IAAI,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAG,OAAO,CAAC;IAC5B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,EAAG,CAAC,CAAC;IAKpB;;;;;;;;;;;;;OAaG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IA6BjC;;;;;OAKG;IACH,MAAM,IAAI,IAAI;CAyCf;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,aAM5B,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Deep-clone a JSON-serializable value.
3
+ *
4
+ * Prefers `structuredClone` when available (Node 17+, modern Deno).
5
+ * Falls back to `JSON.parse(JSON.stringify())` for restricted runtimes
6
+ * (e.g., the Stripe apps Deno sandbox) where `structuredClone` is not
7
+ * exposed.
8
+ *
9
+ * This is safe for custom object field values because they are always
10
+ * JSON-serializable plain data (strings, numbers, booleans, arrays,
11
+ * plain objects) — no Date, Map, Set, or circular references.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare function deepClone<T>(value: T): T;
16
+ //# sourceMappingURL=deep-clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-clone.d.ts","sourceRoot":"","sources":["../../src/runtime/deep-clone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAWxC"}
@@ -0,0 +1,161 @@
1
+ import type { _ExecuteMethodRequest } from './types.js';
2
+ /**
3
+ * Event emitted when a field is set through the proxy.
4
+ *
5
+ * @internal
6
+ */
7
+ export interface _ProxySetEvent {
8
+ /** Discriminant for the proxy:set event. */
9
+ type: 'proxy:set';
10
+ /** Name of the field that was set. */
11
+ field: string;
12
+ /** New value assigned to the field. */
13
+ value: unknown;
14
+ /** Unix epoch milliseconds when the set occurred. */
15
+ timestamp: number;
16
+ }
17
+ /**
18
+ * Event emitted when a save operation begins.
19
+ *
20
+ * @internal
21
+ */
22
+ export interface _SaveBeginEvent {
23
+ /** Discriminant for the save:begin event. */
24
+ type: 'save:begin';
25
+ /** Field data being submitted to the platform. */
26
+ payload: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * Event emitted when a save operation completes successfully.
30
+ *
31
+ * @internal
32
+ */
33
+ export interface _SaveCompleteEvent {
34
+ /** Discriminant for the save:complete event. */
35
+ type: 'save:complete';
36
+ /** Raw response returned by the platform after a successful save. */
37
+ response: Record<string, unknown>;
38
+ }
39
+ /**
40
+ * Event emitted when a method invocation begins.
41
+ *
42
+ * @internal
43
+ */
44
+ export interface _InvokeBeginEvent {
45
+ /** Discriminant for the invoke:begin event. */
46
+ type: 'invoke:begin';
47
+ /** The method invocation request being dispatched. */
48
+ request: _ExecuteMethodRequest;
49
+ }
50
+ /**
51
+ * Event emitted when a method invocation completes successfully.
52
+ *
53
+ * @internal
54
+ */
55
+ export interface _InvokeCompleteEvent {
56
+ /** Discriminant for the invoke:complete event. */
57
+ type: 'invoke:complete';
58
+ /** Value returned by the method. */
59
+ result: unknown;
60
+ }
61
+ /**
62
+ * Event emitted when a method invocation throws an error.
63
+ *
64
+ * @internal
65
+ */
66
+ export interface _InvokeErrorEvent {
67
+ /** Discriminant for the invoke:error event. */
68
+ type: 'invoke:error';
69
+ /** The thrown error value. */
70
+ error: unknown;
71
+ }
72
+ /**
73
+ * Event emitted when a method execution span begins.
74
+ *
75
+ * @internal
76
+ */
77
+ export interface _SpanBeginEvent {
78
+ /** Discriminant for the span:begin event. */
79
+ type: 'span:begin';
80
+ /** Unique identifier for correlating begin/end/error events within a single span. */
81
+ spanId: string;
82
+ /** Name of the method being executed. */
83
+ name: string;
84
+ /** Arguments passed to the method. */
85
+ params?: unknown;
86
+ /** Whether the method is a static class method. */
87
+ isStatic?: boolean;
88
+ /** Nesting depth for recursive or nested method calls. */
89
+ depth?: number;
90
+ }
91
+ /**
92
+ * Event emitted when a method execution span ends successfully.
93
+ *
94
+ * @internal
95
+ */
96
+ export interface _SpanEndEvent {
97
+ /** Discriminant for the span:end event. */
98
+ type: 'span:end';
99
+ /** Unique identifier correlating this event to the matching span:begin. */
100
+ spanId: string;
101
+ /** Name of the method that completed. */
102
+ name: string;
103
+ /** Elapsed time in milliseconds from span:begin to span:end. */
104
+ duration: number;
105
+ /** Value returned by the method, if any. */
106
+ result?: unknown;
107
+ /** Whether the method is a static class method. */
108
+ isStatic?: boolean;
109
+ /** Nesting depth for recursive or nested method calls. */
110
+ depth?: number;
111
+ }
112
+ /**
113
+ * Event emitted when a method execution span encounters an error.
114
+ *
115
+ * @internal
116
+ */
117
+ export interface _SpanErrorEvent {
118
+ /** Discriminant for the span:error event. */
119
+ type: 'span:error';
120
+ /** Unique identifier correlating this event to the matching span:begin. */
121
+ spanId: string;
122
+ /** Name of the method that threw. */
123
+ name: string;
124
+ /** Elapsed time in milliseconds from span:begin to the point of failure. */
125
+ duration: number;
126
+ /** Serializable representation of the thrown error. */
127
+ error: {
128
+ message: string;
129
+ name: string;
130
+ stack?: string;
131
+ };
132
+ /** Whether the method is a static class method. */
133
+ isStatic?: boolean;
134
+ /** Nesting depth for recursive or nested method calls. */
135
+ depth?: number;
136
+ }
137
+ /**
138
+ * Union of all runtime events.
139
+ *
140
+ * @internal
141
+ */
142
+ export type _RuntimeEvent = _InvokeBeginEvent | _InvokeCompleteEvent | _InvokeErrorEvent | _ProxySetEvent | _SaveBeginEvent | _SaveCompleteEvent | _SpanBeginEvent | _SpanEndEvent | _SpanErrorEvent;
143
+ /**
144
+ * Event emitter interface for runtime telemetry.
145
+ *
146
+ * @internal
147
+ */
148
+ export interface _RuntimeEventEmitter {
149
+ /** Broadcasts an event to all subscribed listeners */
150
+ emit(event: _RuntimeEvent): void;
151
+ /** Registers a listener; returns an unsubscribe function */
152
+ subscribe(listener: (event: _RuntimeEvent) => void): () => void;
153
+ }
154
+ /**
155
+ * Creates a new runtime event emitter.
156
+ * Listeners are isolated: if one throws, others still receive the event.
157
+ *
158
+ * @internal
159
+ */
160
+ export declare function _createEventEmitter(): _RuntimeEventEmitter;
161
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/runtime/events.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ import type { _ProxyState } from './types.js';
2
+ /**
3
+ * Flushes pending field updates into the slated-updates accumulator.
4
+ * Strips the fields. prefix from keys so the response envelope uses bare property names.
5
+ * Returns the number of unique fields flushed.
6
+ * @internal
7
+ */
8
+ export declare function _flushPendingToSlated(state: _ProxyState): number;
9
+ //# sourceMappingURL=flush-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flush-helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/flush-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAWhE"}
@@ -0,0 +1,19 @@
1
+ import type { _ExecuteMethodRequest } from './types.js';
2
+ import type { _RuntimeEventEmitter } from './events.js';
3
+ /**
4
+ * Options for executing a custom object method.
5
+ *
6
+ * @internal
7
+ */
8
+ export interface _ExecuteMethodOptions {
9
+ /** Event emitter for telemetry */
10
+ eventEmitter?: _RuntimeEventEmitter;
11
+ }
12
+ /**
13
+ * Executes a custom object method (instance or class/static).
14
+ * Dispatches to the appropriate handler based on whether instanceId is present.
15
+ *
16
+ * @internal
17
+ */
18
+ export declare function _executeMethod(request: _ExecuteMethodRequest, options?: _ExecuteMethodOptions): Promise<unknown>;
19
+ //# sourceMappingURL=invoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/runtime/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAoDxD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,OAAO,CAAC,CAyClB"}
@@ -0,0 +1,44 @@
1
+ import type { BaseObject } from './base-object.js';
2
+ import type { _RuntimeEventEmitter } from './events.js';
3
+ /**
4
+ * Options for persistence operations.
5
+ *
6
+ * @internal
7
+ */
8
+ export interface _PersistOptions {
9
+ /** Event emitter for telemetry */
10
+ eventEmitter?: _RuntimeEventEmitter;
11
+ /** Fetch function (for testing with mocks) */
12
+ fetchFn?: typeof fetch;
13
+ /** Base URL for the persistence API */
14
+ baseUrl?: string;
15
+ }
16
+ /**
17
+ * Assembles an update payload from pending proxy updates.
18
+ *
19
+ * Fields prefixed with `fields.` are grouped into a nested `fields` object.
20
+ * All other fields appear at the top level.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * assemblePayload([
25
+ * { field: 'status', value: 'active' },
26
+ * { field: 'fields.email', value: 'alice@example.com' },
27
+ * ]);
28
+ * // Returns: { status: 'active', fields: { email: 'alice@example.com' } }
29
+ * ```
30
+ *
31
+ * @internal
32
+ */
33
+ export declare function _assemblePayload(pendingUpdates: {
34
+ field: string;
35
+ value: unknown;
36
+ }[]): Record<string, unknown>;
37
+ /**
38
+ * Persists a custom object instance to the platform.
39
+ * Throws if the object is not proxied.
40
+ *
41
+ * @internal
42
+ */
43
+ export declare function _persistObject(obj: BaseObject, options?: _PersistOptions): Promise<void>;
44
+ //# sourceMappingURL=persist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/runtime/persist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,GAClD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBzB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAqDf"}
@@ -0,0 +1,5 @@
1
+ /** Keys that must never be set or deleted via proxies to prevent prototype pollution. @internal */
2
+ export declare const STRIPE_CONTROLLED_KEYS: Set<string>;
3
+ /** Prefix for user-defined fields in the proxy state map. @internal */
4
+ export declare const FIELDS_PREFIX = "fields.";
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/runtime/proxy/constants.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,eAAO,MAAM,sBAAsB,aAAqD,CAAC;AAEzF,uEAAuE;AACvE,eAAO,MAAM,aAAa,YAAY,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { _ProxyState } from '../types.js';
2
+ import type { _RuntimeEventEmitter } from '../events.js';
3
+ /**
4
+ * Creates a proxy over the fields object that tracks changes as "fields.key" updates.
5
+ * The getEventEmitter function allows for lazy/dynamic binding of the event emitter.
6
+ *
7
+ * When a property is read and its value is an object, a recursive nested proxy is
8
+ * returned so that mutations to any depth of sub-properties are recorded against
9
+ * the top-level fields key. Proxy instances are cached in a Map per top-level
10
+ * field so that repeated `.get` accesses return a stable reference.
11
+ *
12
+ * Array mutations (push, splice, index assignment) are tracked automatically because
13
+ * arrays are objects — the recursive `get` trap wraps the array in a proxy whose
14
+ * `set` trap fires on index assignment and on mutation-method internal writes.
15
+ *
16
+ * @internal
17
+ */
18
+ export declare function createFieldsProxy<T extends Record<string, unknown>>(target: T, state: _ProxyState, getEventEmitter?: () => _RuntimeEventEmitter | undefined): T;
19
+ //# sourceMappingURL=fields-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields-proxy.d.ts","sourceRoot":"","sources":["../../../src/runtime/proxy/fields-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGzD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,WAAW,EAClB,eAAe,CAAC,EAAE,MAAM,oBAAoB,GAAG,SAAS,GACvD,CAAC,CAoKH"}
@@ -0,0 +1,5 @@
1
+ export type { _CreateProxyOptions, _ProxiedObject } from './types.js';
2
+ export { _createInstanceProxy, _getProxyState, _commitProxyState, __hasPendingChanges, __queueSave, _getSlatedUpdates, _clearSlatedUpdates, _buildMethodResponse, setGlobalEventEmitter, getGlobalEventEmitter, } from './instance-proxy.js';
3
+ export { createFieldsProxy } from './fields-proxy.js';
4
+ export { STRIPE_CONTROLLED_KEYS, FIELDS_PREFIX } from './constants.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/proxy/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { type _ProxyState } from '../types.js';
2
+ import type { BaseObject } from '../base-object.js';
3
+ import type { _RuntimeEventEmitter } from '../events.js';
4
+ import type { _CreateProxyOptions, _ProxiedObject } from './types.js';
5
+ /**
6
+ * Sets the global event emitter used during method execution.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function setGlobalEventEmitter(emitter: _RuntimeEventEmitter | undefined): void;
11
+ /**
12
+ * Gets the global event emitter, if set.
13
+ *
14
+ * @internal
15
+ */
16
+ export declare function getGlobalEventEmitter(): _RuntimeEventEmitter | undefined;
17
+ /**
18
+ * Creates a proxied custom object instance with change tracking.
19
+ *
20
+ * @internal
21
+ */
22
+ export declare function _createInstanceProxy<T extends BaseObject>(instance: T, options?: _CreateProxyOptions): _ProxiedObject<T>;
23
+ /**
24
+ * Extracts the proxy state from a proxied object.
25
+ * Returns undefined if the object is not proxied.
26
+ *
27
+ * @internal
28
+ */
29
+ export declare function _getProxyState(obj: BaseObject): _ProxyState | undefined;
30
+ /**
31
+ * Commits the proxy state: clears pending updates and updates the saved snapshot.
32
+ *
33
+ * @internal
34
+ */
35
+ export declare function _commitProxyState(state: _ProxyState): void;
36
+ /**
37
+ * Checks if a proxied object has pending changes.
38
+ *
39
+ * @internal
40
+ */
41
+ export declare function __hasPendingChanges(obj: BaseObject): boolean;
42
+ /**
43
+ * Flushes pending field changes into the proxy's slated-updates accumulator.
44
+ *
45
+ * Called by the auto-save code injected at the end of each `@Action` method.
46
+ * BaseObject.save() performs an equivalent flush directly via the shared
47
+ * _flushPendingToSlated helper.
48
+ *
49
+ * @internal
50
+ */
51
+ export declare function __queueSave(obj: BaseObject): void;
52
+ /**
53
+ * Returns a snapshot of the accumulated slated updates from save() or
54
+ * __queueSave() calls during an action. Callers should call
55
+ * _clearSlatedUpdates after reading to reset for the next invocation.
56
+ *
57
+ * @internal
58
+ */
59
+ export declare function _getSlatedUpdates(obj: BaseObject): Record<string, unknown>;
60
+ /**
61
+ * Clears the slated-updates accumulator on an instance.
62
+ *
63
+ * Called twice during executeMethod: once before the action (to ensure
64
+ * no stale state from a previous invocation leaks in) and once inside
65
+ * buildEnvelope after the accumulated updates have been read.
66
+ *
67
+ * @internal
68
+ */
69
+ export declare function _clearSlatedUpdates(obj: BaseObject): void;
70
+ /**
71
+ * Builds the ExecuteMethodResponse envelope for a completed action.
72
+ * Reads and clears the slated-updates accumulator, returning
73
+ * `{ methodReturnValue, updatedFields }`.
74
+ *
75
+ * @internal
76
+ */
77
+ export declare function _buildMethodResponse(obj: BaseObject, methodReturnValue: unknown): {
78
+ methodReturnValue: unknown;
79
+ updatedFields: Record<string, unknown>;
80
+ };
81
+ //# sourceMappingURL=instance-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-proxy.d.ts","sourceRoot":"","sources":["../../../src/runtime/proxy/instance-proxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyCtE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,CAErF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,GAAG,SAAS,CAExE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,UAAU,EACvD,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,mBAAmB,GAC5B,cAAc,CAAC,CAAC,CAAC,CAgKnB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAK1D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAG5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAajD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAKzD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,UAAU,EACf,iBAAiB,EAAE,OAAO,GACzB;IAAE,iBAAiB,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAIxE"}
@@ -0,0 +1,25 @@
1
+ import type { _ProxyState, _SaveHandler } from '../types.js';
2
+ import type { _RuntimeEventEmitter } from '../events.js';
3
+ /**
4
+ * Options for creating a proxied custom object instance.
5
+ *
6
+ * @internal
7
+ */
8
+ export interface _CreateProxyOptions {
9
+ /** Event emitter for telemetry */
10
+ eventEmitter?: _RuntimeEventEmitter;
11
+ /** Save handler for persistence */
12
+ saveHandler?: _SaveHandler;
13
+ }
14
+ /**
15
+ * Result of creating a proxied instance.
16
+ *
17
+ * @internal
18
+ */
19
+ export interface _ProxiedObject<T> {
20
+ /** The proxied instance */
21
+ proxy: T;
22
+ /** The proxy state for change tracking */
23
+ state: _ProxyState;
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/proxy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,kCAAkC;IAClC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,mCAAmC;IACnC,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,2BAA2B;IAC3B,KAAK,EAAE,CAAC,CAAC;IACT,0CAA0C;IAC1C,KAAK,EAAE,WAAW,CAAC;CACpB"}
@@ -0,0 +1,40 @@
1
+ import type { BaseObject } from './base-object.js';
2
+ import type { _PlatformMetadata } from './types.js';
3
+ /**
4
+ * Constructor type for custom object classes.
5
+ *
6
+ * @internal
7
+ */
8
+ export interface _CustomObjectConstructor<T extends BaseObject = BaseObject> {
9
+ /** Constructs a new instance of the custom object class. */
10
+ new (): T;
11
+ /** Platform metadata attached by the `CustomObject` decorator at build time */
12
+ __platformMeta__?: _PlatformMetadata;
13
+ }
14
+ /**
15
+ * Registers a custom object class by its api name.
16
+ * Validates that the class has platform metadata attached.
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function _registerClass<T extends BaseObject>(constructor: _CustomObjectConstructor<T>): void;
21
+ /**
22
+ * Retrieves a registered custom object constructor by api name.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare function _getRegisteredClass(apiName: string): _CustomObjectConstructor | undefined;
27
+ /**
28
+ * Clears all registered classes.
29
+ * Primarily for testing.
30
+ *
31
+ * @internal
32
+ */
33
+ export declare function _clearRegistry(): void;
34
+ /**
35
+ * Returns all registered API names.
36
+ *
37
+ * @internal
38
+ */
39
+ export declare function _getRegisteredApiNames(): string[];
40
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/runtime/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IACzE,4DAA4D;IAC5D,QAAQ,CAAC,CAAC;IACV,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;CACtC;AAOD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EACjD,WAAW,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACvC,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GACd,wBAAwB,GAAG,SAAS,CAEtC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Gets a symbol-keyed property from an object.
3
+ * TypeScript's type system cannot express `Record<symbol, T>` lookups without a cast;
4
+ * centralizing the cast here keeps all other call sites lint-clean.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare function getSymbolProp<T>(obj: object, sym: symbol): T | undefined;
9
+ /**
10
+ * Sets a symbol-keyed property on an object.
11
+ * TypeScript's type system cannot express `Record<symbol, T>` assignments without a cast;
12
+ * centralizing the cast here keeps all other call sites lint-clean.
13
+ *
14
+ * @internal
15
+ */
16
+ export declare function setSymbolProp(obj: object, sym: symbol, value: unknown): void;
17
+ //# sourceMappingURL=symbol-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbol-helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/symbol-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;AAO1E;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAG5E"}