@distilled.cloud/core 0.0.0-john

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.
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Common error types shared across SDKs.
3
+ *
4
+ * Each SDK defines its own provider-specific errors (e.g., Unauthorized, NotFound)
5
+ * using the category system. This module provides base error types and utilities
6
+ * that are used across all SDKs.
7
+ */
8
+ import * as Schema from "effect/Schema";
9
+ import * as Category from "./category.ts";
10
+ declare const Unauthorized_base: Schema.ErrorClass<Unauthorized, Schema.TaggedStruct<"Unauthorized", {
11
+ readonly message: Schema.String;
12
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
13
+ "@distilled.cloud/error/categories": {
14
+ AuthError: true;
15
+ };
16
+ });
17
+ /**
18
+ * Unauthorized - Authentication failure (401).
19
+ */
20
+ export declare class Unauthorized extends Unauthorized_base {
21
+ }
22
+ declare const Forbidden_base: Schema.ErrorClass<Forbidden, Schema.TaggedStruct<"Forbidden", {
23
+ readonly message: Schema.String;
24
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
25
+ "@distilled.cloud/error/categories": {
26
+ AuthError: true;
27
+ };
28
+ });
29
+ /**
30
+ * Forbidden - Access denied (403).
31
+ */
32
+ export declare class Forbidden extends Forbidden_base {
33
+ }
34
+ declare const NotFound_base: Schema.ErrorClass<NotFound, Schema.TaggedStruct<"NotFound", {
35
+ readonly message: Schema.String;
36
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
37
+ "@distilled.cloud/error/categories": {
38
+ NotFoundError: true;
39
+ };
40
+ });
41
+ /**
42
+ * NotFound - Resource not found (404).
43
+ */
44
+ export declare class NotFound extends NotFound_base {
45
+ }
46
+ declare const BadRequest_base: Schema.ErrorClass<BadRequest, Schema.TaggedStruct<"BadRequest", {
47
+ readonly message: Schema.String;
48
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
49
+ "@distilled.cloud/error/categories": {
50
+ BadRequestError: true;
51
+ };
52
+ });
53
+ /**
54
+ * BadRequest - Invalid request (400).
55
+ */
56
+ export declare class BadRequest extends BadRequest_base {
57
+ }
58
+ declare const Conflict_base: Schema.ErrorClass<Conflict, Schema.TaggedStruct<"Conflict", {
59
+ readonly message: Schema.String;
60
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
61
+ "@distilled.cloud/error/categories": {
62
+ ConflictError: true;
63
+ };
64
+ });
65
+ /**
66
+ * Conflict - Resource conflict (409).
67
+ */
68
+ export declare class Conflict extends Conflict_base {
69
+ }
70
+ declare const UnprocessableEntity_base: Schema.ErrorClass<UnprocessableEntity, Schema.TaggedStruct<"UnprocessableEntity", {
71
+ readonly message: Schema.String;
72
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
73
+ "@distilled.cloud/error/categories": {
74
+ BadRequestError: true;
75
+ };
76
+ });
77
+ /**
78
+ * UnprocessableEntity - Validation error (422).
79
+ */
80
+ export declare class UnprocessableEntity extends UnprocessableEntity_base {
81
+ }
82
+ declare const TooManyRequests_base: Schema.ErrorClass<TooManyRequests, Schema.TaggedStruct<"TooManyRequests", {
83
+ readonly message: Schema.String;
84
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
85
+ "@distilled.cloud/error/categories": {
86
+ ThrottlingError: true;
87
+ };
88
+ }) & (new (...args: any[]) => {
89
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
90
+ });
91
+ /**
92
+ * TooManyRequests - Rate limited (429).
93
+ */
94
+ export declare class TooManyRequests extends TooManyRequests_base {
95
+ }
96
+ declare const Locked_base: Schema.ErrorClass<Locked, Schema.TaggedStruct<"Locked", {
97
+ readonly message: Schema.String;
98
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
99
+ "@distilled.cloud/error/categories": {
100
+ LockedError: true;
101
+ };
102
+ }) & (new (...args: any[]) => {
103
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
104
+ });
105
+ /**
106
+ * Locked - Resource locked (423).
107
+ */
108
+ export declare class Locked extends Locked_base {
109
+ }
110
+ declare const InternalServerError_base: Schema.ErrorClass<InternalServerError, Schema.TaggedStruct<"InternalServerError", {
111
+ readonly message: Schema.String;
112
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
113
+ "@distilled.cloud/error/categories": {
114
+ ServerError: true;
115
+ };
116
+ }) & (new (...args: any[]) => {
117
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
118
+ });
119
+ /**
120
+ * InternalServerError - Server error (500).
121
+ */
122
+ export declare class InternalServerError extends InternalServerError_base {
123
+ }
124
+ declare const BadGateway_base: Schema.ErrorClass<BadGateway, Schema.TaggedStruct<"BadGateway", {
125
+ readonly message: Schema.String;
126
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
127
+ "@distilled.cloud/error/categories": {
128
+ ServerError: true;
129
+ };
130
+ }) & (new (...args: any[]) => {
131
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
132
+ });
133
+ /**
134
+ * BadGateway - Bad gateway (502).
135
+ */
136
+ export declare class BadGateway extends BadGateway_base {
137
+ }
138
+ declare const ServiceUnavailable_base: Schema.ErrorClass<ServiceUnavailable, Schema.TaggedStruct<"ServiceUnavailable", {
139
+ readonly message: Schema.String;
140
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
141
+ "@distilled.cloud/error/categories": {
142
+ ServerError: true;
143
+ };
144
+ }) & (new (...args: any[]) => {
145
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
146
+ });
147
+ /**
148
+ * ServiceUnavailable - Service unavailable (503).
149
+ */
150
+ export declare class ServiceUnavailable extends ServiceUnavailable_base {
151
+ }
152
+ declare const GatewayTimeout_base: Schema.ErrorClass<GatewayTimeout, Schema.TaggedStruct<"GatewayTimeout", {
153
+ readonly message: Schema.String;
154
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
155
+ "@distilled.cloud/error/categories": {
156
+ ServerError: true;
157
+ };
158
+ }) & (new (...args: any[]) => {
159
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
160
+ });
161
+ /**
162
+ * GatewayTimeout - Gateway timeout (504).
163
+ */
164
+ export declare class GatewayTimeout extends GatewayTimeout_base {
165
+ }
166
+ declare const ConfigError_base: Schema.ErrorClass<ConfigError, Schema.TaggedStruct<"ConfigError", {
167
+ readonly message: Schema.String;
168
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
169
+ "@distilled.cloud/error/categories": {
170
+ ConfigurationError: true;
171
+ };
172
+ });
173
+ /**
174
+ * Configuration error - missing or invalid configuration.
175
+ */
176
+ export declare class ConfigError extends ConfigError_base {
177
+ }
178
+ /**
179
+ * Mapping from HTTP status codes to common error classes.
180
+ */
181
+ export declare const HTTP_STATUS_MAP: {
182
+ readonly 400: typeof BadRequest;
183
+ readonly 401: typeof Unauthorized;
184
+ readonly 403: typeof Forbidden;
185
+ readonly 404: typeof NotFound;
186
+ readonly 409: typeof Conflict;
187
+ readonly 422: typeof UnprocessableEntity;
188
+ readonly 423: typeof Locked;
189
+ readonly 429: typeof TooManyRequests;
190
+ readonly 500: typeof InternalServerError;
191
+ readonly 502: typeof BadGateway;
192
+ readonly 503: typeof ServiceUnavailable;
193
+ readonly 504: typeof GatewayTimeout;
194
+ };
195
+ /**
196
+ * HTTP status codes that are considered "default" errors (always present).
197
+ * These are excluded from per-operation error types since they're handled globally.
198
+ */
199
+ export declare const DEFAULT_ERROR_STATUSES: Set<number>;
200
+ /**
201
+ * All common API error classes.
202
+ */
203
+ export declare const API_ERRORS: readonly [typeof Unauthorized, typeof Forbidden, typeof NotFound, typeof BadRequest, typeof Conflict, typeof UnprocessableEntity, typeof TooManyRequests, typeof Locked, typeof InternalServerError, typeof BadGateway, typeof ServiceUnavailable, typeof GatewayTimeout];
204
+ /**
205
+ * Default errors that apply to ALL operations.
206
+ * These are infrastructure-level errors that can occur regardless of the operation.
207
+ */
208
+ export declare const DEFAULT_ERRORS: readonly [typeof Unauthorized, typeof TooManyRequests, typeof InternalServerError, typeof BadGateway, typeof ServiceUnavailable, typeof GatewayTimeout];
209
+ export type DefaultErrors = InstanceType<(typeof DEFAULT_ERRORS)[number]>;
210
+ export {};
211
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;;;;;;;;AAM1C;;GAEG;AACH,qBAAa,YAAa,SAAQ,iBAGJ;CAAG;;;;;;;;AAEjC;;GAEG;AACH,qBAAa,SAAU,SAAQ,cAGD;CAAG;;;;;;;;AAEjC;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAEK;CAAG;;;;;;;;AAEtC;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAGI;CAAG;;;;;;;;AAEvC;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAEK;CAAG;;;;;;;;AAEtC;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,wBAGL;CAAG;;;;;;;;;;AAEvC;;GAEG;AACH,qBAAa,eAAgB,SAAQ,oBAMpC;CAAG;;;;;;;;;;AAEJ;;GAEG;AACH,qBAAa,MAAO,SAAQ,WAE+B;CAAG;;;;;;;;;;AAE9D;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,wBAGiB;CAAG;;;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,UAAW,SAAQ,eAG0B;CAAG;;;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,uBAGkB;CAAG;;;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,cAAe,SAAQ,mBAGsB;CAAG;;;;;;;;AAE7D;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAGM;CAAG;AAM1C;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAalB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,sBAAsB,aAA0C,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,UAAU,2QAab,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc,yJAOjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
package/lib/errors.js ADDED
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Common error types shared across SDKs.
3
+ *
4
+ * Each SDK defines its own provider-specific errors (e.g., Unauthorized, NotFound)
5
+ * using the category system. This module provides base error types and utilities
6
+ * that are used across all SDKs.
7
+ */
8
+ import * as Schema from "effect/Schema";
9
+ import * as Category from "./category.js";
10
+ // ============================================================================
11
+ // Common HTTP Status Error Classes
12
+ // ============================================================================
13
+ /**
14
+ * Unauthorized - Authentication failure (401).
15
+ */
16
+ export class Unauthorized extends Schema.TaggedErrorClass()("Unauthorized", { message: Schema.String }).pipe(Category.withAuthError) {
17
+ }
18
+ /**
19
+ * Forbidden - Access denied (403).
20
+ */
21
+ export class Forbidden extends Schema.TaggedErrorClass()("Forbidden", { message: Schema.String }).pipe(Category.withAuthError) {
22
+ }
23
+ /**
24
+ * NotFound - Resource not found (404).
25
+ */
26
+ export class NotFound extends Schema.TaggedErrorClass()("NotFound", {
27
+ message: Schema.String,
28
+ }).pipe(Category.withNotFoundError) {
29
+ }
30
+ /**
31
+ * BadRequest - Invalid request (400).
32
+ */
33
+ export class BadRequest extends Schema.TaggedErrorClass()("BadRequest", { message: Schema.String }).pipe(Category.withBadRequestError) {
34
+ }
35
+ /**
36
+ * Conflict - Resource conflict (409).
37
+ */
38
+ export class Conflict extends Schema.TaggedErrorClass()("Conflict", {
39
+ message: Schema.String,
40
+ }).pipe(Category.withConflictError) {
41
+ }
42
+ /**
43
+ * UnprocessableEntity - Validation error (422).
44
+ */
45
+ export class UnprocessableEntity extends Schema.TaggedErrorClass()("UnprocessableEntity", { message: Schema.String }).pipe(Category.withBadRequestError) {
46
+ }
47
+ /**
48
+ * TooManyRequests - Rate limited (429).
49
+ */
50
+ export class TooManyRequests extends Schema.TaggedErrorClass()("TooManyRequests", { message: Schema.String }).pipe(Category.withThrottlingError, Category.withRetryable({ throttling: true })) {
51
+ }
52
+ /**
53
+ * Locked - Resource locked (423).
54
+ */
55
+ export class Locked extends Schema.TaggedErrorClass()("Locked", {
56
+ message: Schema.String,
57
+ }).pipe(Category.withLockedError, Category.withRetryable()) {
58
+ }
59
+ /**
60
+ * InternalServerError - Server error (500).
61
+ */
62
+ export class InternalServerError extends Schema.TaggedErrorClass()("InternalServerError", { message: Schema.String }).pipe(Category.withServerError, Category.withRetryable()) {
63
+ }
64
+ /**
65
+ * BadGateway - Bad gateway (502).
66
+ */
67
+ export class BadGateway extends Schema.TaggedErrorClass()("BadGateway", { message: Schema.String }).pipe(Category.withServerError, Category.withRetryable()) {
68
+ }
69
+ /**
70
+ * ServiceUnavailable - Service unavailable (503).
71
+ */
72
+ export class ServiceUnavailable extends Schema.TaggedErrorClass()("ServiceUnavailable", { message: Schema.String }).pipe(Category.withServerError, Category.withRetryable()) {
73
+ }
74
+ /**
75
+ * GatewayTimeout - Gateway timeout (504).
76
+ */
77
+ export class GatewayTimeout extends Schema.TaggedErrorClass()("GatewayTimeout", { message: Schema.String }).pipe(Category.withServerError, Category.withRetryable()) {
78
+ }
79
+ /**
80
+ * Configuration error - missing or invalid configuration.
81
+ */
82
+ export class ConfigError extends Schema.TaggedErrorClass()("ConfigError", { message: Schema.String }).pipe(Category.withConfigurationError) {
83
+ }
84
+ // ============================================================================
85
+ // Error Maps
86
+ // ============================================================================
87
+ /**
88
+ * Mapping from HTTP status codes to common error classes.
89
+ */
90
+ export const HTTP_STATUS_MAP = {
91
+ 400: BadRequest,
92
+ 401: Unauthorized,
93
+ 403: Forbidden,
94
+ 404: NotFound,
95
+ 409: Conflict,
96
+ 422: UnprocessableEntity,
97
+ 423: Locked,
98
+ 429: TooManyRequests,
99
+ 500: InternalServerError,
100
+ 502: BadGateway,
101
+ 503: ServiceUnavailable,
102
+ 504: GatewayTimeout,
103
+ };
104
+ /**
105
+ * HTTP status codes that are considered "default" errors (always present).
106
+ * These are excluded from per-operation error types since they're handled globally.
107
+ */
108
+ export const DEFAULT_ERROR_STATUSES = new Set([401, 429, 500, 502, 503, 504]);
109
+ /**
110
+ * All common API error classes.
111
+ */
112
+ export const API_ERRORS = [
113
+ Unauthorized,
114
+ Forbidden,
115
+ NotFound,
116
+ BadRequest,
117
+ Conflict,
118
+ UnprocessableEntity,
119
+ TooManyRequests,
120
+ Locked,
121
+ InternalServerError,
122
+ BadGateway,
123
+ ServiceUnavailable,
124
+ GatewayTimeout,
125
+ ];
126
+ /**
127
+ * Default errors that apply to ALL operations.
128
+ * These are infrastructure-level errors that can occur regardless of the operation.
129
+ */
130
+ export const DEFAULT_ERRORS = [
131
+ Unauthorized,
132
+ TooManyRequests,
133
+ InternalServerError,
134
+ BadGateway,
135
+ ServiceUnavailable,
136
+ GatewayTimeout,
137
+ ];
138
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,gBAAgB,EAAgB,CACvE,cAAc,EACd,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;CAAG;AAEjC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,gBAAgB,EAAa,CACjE,WAAW,EACX,EAAE,OAAO,EAAE,MAAM,CAAC,MAA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,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,cAAc;CACX,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,mBAAmB;IACnB,eAAe;IACf,MAAM;IACN,mBAAmB;IACnB,UAAU;IACV,kBAAkB;IAClB,cAAc;CACN,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY;IACZ,eAAe;IACf,mBAAmB;IACnB,UAAU;IACV,kBAAkB;IAClB,cAAc;CACN,CAAC"}
@@ -0,0 +1,44 @@
1
+ export interface JsonPatchOperation {
2
+ op: "add" | "remove" | "replace" | "move" | "copy" | "test";
3
+ path: string;
4
+ value?: unknown;
5
+ from?: string;
6
+ }
7
+ export type JsonPatch = JsonPatchOperation[];
8
+ export interface PatchFile {
9
+ description: string;
10
+ patches: JsonPatch;
11
+ }
12
+ /**
13
+ * Parse a JSON Pointer (RFC 6901) path into segments.
14
+ */
15
+ export declare function parseJsonPointer(pointer: string): string[];
16
+ /**
17
+ * Get a value at a JSON Pointer path.
18
+ */
19
+ export declare function getValueAtPath(obj: unknown, pointer: string): unknown;
20
+ /**
21
+ * Set a value at a JSON Pointer path.
22
+ */
23
+ export declare function setValueAtPath(obj: unknown, pointer: string, value: unknown): void;
24
+ /**
25
+ * Remove a value at a JSON Pointer path.
26
+ */
27
+ export declare function removeValueAtPath(obj: unknown, pointer: string): void;
28
+ /**
29
+ * Apply a single JSON Patch operation.
30
+ */
31
+ export declare function applyOperation(obj: unknown, operation: JsonPatchOperation): void;
32
+ /**
33
+ * Apply a JSON Patch to an object (mutates in place).
34
+ */
35
+ export declare function applyPatch(obj: unknown, patch: JsonPatch): void;
36
+ /**
37
+ * Load and apply all patches from a directory.
38
+ * Finds all *.patch.json files and applies them.
39
+ */
40
+ export declare function applyAllPatches(spec: unknown, patchDir: string): {
41
+ applied: string[];
42
+ errors: string[];
43
+ };
44
+ //# sourceMappingURL=json-patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-patch.d.ts","sourceRoot":"","sources":["../src/json-patch.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC;AAE7C,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC;CACpB;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAS1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAiBrE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,GACb,IAAI,CAuCN;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAgCrE;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,kBAAkB,GAC5B,IAAI,CA0CN;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAI/D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,GACf;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CA6BzC"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * JSON Patch (RFC 6902) Implementation
3
+ *
4
+ * Provides a unified spec patching system for all SDKs.
5
+ * Patches are applied to OpenAPI/Discovery/Smithy specs before code generation
6
+ * to add error types, fix nullable fields, mark sensitive data, etc.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { applyAllPatches } from "@distilled.cloud/core/json-patch";
11
+ *
12
+ * const spec = JSON.parse(fs.readFileSync("openapi.json", "utf-8"));
13
+ * const { applied, errors } = applyAllPatches(spec, "./patches");
14
+ * ```
15
+ */
16
+ import * as fs from "fs";
17
+ import * as path from "path";
18
+ // ============================================================================
19
+ // JSON Pointer (RFC 6901)
20
+ // ============================================================================
21
+ /**
22
+ * Parse a JSON Pointer (RFC 6901) path into segments.
23
+ */
24
+ export function parseJsonPointer(pointer) {
25
+ if (pointer === "")
26
+ return [];
27
+ if (!pointer.startsWith("/")) {
28
+ throw new Error(`Invalid JSON Pointer: ${pointer}`);
29
+ }
30
+ return pointer
31
+ .slice(1)
32
+ .split("/")
33
+ .map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
34
+ }
35
+ /**
36
+ * Get a value at a JSON Pointer path.
37
+ */
38
+ export function getValueAtPath(obj, pointer) {
39
+ const segments = parseJsonPointer(pointer);
40
+ let current = obj;
41
+ for (const segment of segments) {
42
+ if (current === null || typeof current !== "object") {
43
+ throw new Error(`Cannot traverse path ${pointer}: not an object`);
44
+ }
45
+ if (Array.isArray(current)) {
46
+ const index = segment === "-" ? current.length : parseInt(segment, 10);
47
+ current = current[index];
48
+ }
49
+ else {
50
+ current = current[segment];
51
+ }
52
+ }
53
+ return current;
54
+ }
55
+ /**
56
+ * Set a value at a JSON Pointer path.
57
+ */
58
+ export function setValueAtPath(obj, pointer, value) {
59
+ const segments = parseJsonPointer(pointer);
60
+ if (segments.length === 0) {
61
+ throw new Error("Cannot set value at root path");
62
+ }
63
+ let current = obj;
64
+ for (let i = 0; i < segments.length - 1; i++) {
65
+ const segment = segments[i];
66
+ if (current === null || typeof current !== "object") {
67
+ throw new Error(`Cannot traverse path ${pointer}: not an object`);
68
+ }
69
+ if (Array.isArray(current)) {
70
+ const index = parseInt(segment, 10);
71
+ current = current[index];
72
+ }
73
+ else {
74
+ current = current[segment];
75
+ }
76
+ }
77
+ const lastSegment = segments[segments.length - 1];
78
+ if (current === null || typeof current !== "object") {
79
+ throw new Error(`Cannot set value at path ${pointer}: parent is not an object`);
80
+ }
81
+ if (Array.isArray(current)) {
82
+ const index = lastSegment === "-" ? current.length : parseInt(lastSegment, 10);
83
+ if (lastSegment === "-") {
84
+ current.push(value);
85
+ }
86
+ else {
87
+ current[index] = value;
88
+ }
89
+ }
90
+ else {
91
+ current[lastSegment] = value;
92
+ }
93
+ }
94
+ /**
95
+ * Remove a value at a JSON Pointer path.
96
+ */
97
+ export function removeValueAtPath(obj, pointer) {
98
+ const segments = parseJsonPointer(pointer);
99
+ if (segments.length === 0) {
100
+ throw new Error("Cannot remove root");
101
+ }
102
+ let current = obj;
103
+ for (let i = 0; i < segments.length - 1; i++) {
104
+ const segment = segments[i];
105
+ if (current === null || typeof current !== "object") {
106
+ throw new Error(`Cannot traverse path ${pointer}: not an object`);
107
+ }
108
+ if (Array.isArray(current)) {
109
+ current = current[parseInt(segment, 10)];
110
+ }
111
+ else {
112
+ current = current[segment];
113
+ }
114
+ }
115
+ const lastSegment = segments[segments.length - 1];
116
+ if (current === null || typeof current !== "object") {
117
+ throw new Error(`Cannot remove at path ${pointer}: parent is not an object`);
118
+ }
119
+ if (Array.isArray(current)) {
120
+ current.splice(parseInt(lastSegment, 10), 1);
121
+ }
122
+ else {
123
+ delete current[lastSegment];
124
+ }
125
+ }
126
+ // ============================================================================
127
+ // Patch Operations
128
+ // ============================================================================
129
+ /**
130
+ * Apply a single JSON Patch operation.
131
+ */
132
+ export function applyOperation(obj, operation) {
133
+ switch (operation.op) {
134
+ case "add":
135
+ setValueAtPath(obj, operation.path, operation.value);
136
+ break;
137
+ case "remove":
138
+ removeValueAtPath(obj, operation.path);
139
+ break;
140
+ case "replace":
141
+ // For replace, the path must exist
142
+ getValueAtPath(obj, operation.path); // throws if doesn't exist
143
+ setValueAtPath(obj, operation.path, operation.value);
144
+ break;
145
+ case "move": {
146
+ if (!operation.from)
147
+ throw new Error("move operation requires 'from'");
148
+ const moveValue = getValueAtPath(obj, operation.from);
149
+ removeValueAtPath(obj, operation.from);
150
+ setValueAtPath(obj, operation.path, moveValue);
151
+ break;
152
+ }
153
+ case "copy": {
154
+ if (!operation.from)
155
+ throw new Error("copy operation requires 'from'");
156
+ const copyValue = getValueAtPath(obj, operation.from);
157
+ setValueAtPath(obj, operation.path, JSON.parse(JSON.stringify(copyValue)));
158
+ break;
159
+ }
160
+ case "test": {
161
+ const testValue = getValueAtPath(obj, operation.path);
162
+ if (JSON.stringify(testValue) !== JSON.stringify(operation.value)) {
163
+ throw new Error(`Test operation failed at ${operation.path}: expected ${JSON.stringify(operation.value)}, got ${JSON.stringify(testValue)}`);
164
+ }
165
+ break;
166
+ }
167
+ default:
168
+ throw new Error(`Unknown operation: ${operation.op}`);
169
+ }
170
+ }
171
+ /**
172
+ * Apply a JSON Patch to an object (mutates in place).
173
+ */
174
+ export function applyPatch(obj, patch) {
175
+ for (const operation of patch) {
176
+ applyOperation(obj, operation);
177
+ }
178
+ }
179
+ /**
180
+ * Load and apply all patches from a directory.
181
+ * Finds all *.patch.json files and applies them.
182
+ */
183
+ export function applyAllPatches(spec, patchDir) {
184
+ const applied = [];
185
+ const errors = [];
186
+ if (!fs.existsSync(patchDir)) {
187
+ return { applied, errors };
188
+ }
189
+ // Find all .patch.json files
190
+ const files = fs
191
+ .readdirSync(patchDir)
192
+ .filter((f) => f.endsWith(".patch.json"))
193
+ .sort(); // Sort for deterministic application order
194
+ for (const file of files) {
195
+ const filePath = path.join(patchDir, file);
196
+ try {
197
+ const content = fs.readFileSync(filePath, "utf-8");
198
+ const patchFile = JSON.parse(content);
199
+ applyPatch(spec, patchFile.patches);
200
+ applied.push(`${file}: ${patchFile.description}`);
201
+ }
202
+ catch (error) {
203
+ errors.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
204
+ }
205
+ }
206
+ return { applied, errors };
207
+ }
208
+ //# sourceMappingURL=json-patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-patch.js","sourceRoot":"","sources":["../src/json-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAoB7B,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,OAAO;SACX,KAAK,CAAC,CAAC,CAAC;SACR,KAAK,CAAC,GAAG,CAAC;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