@myxtra/microservice 1.17.0-alpha.0 → 1.18.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -7
- package/dist/index.mjs +294 -118
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FastifyPluginAsync, FastifyPluginCallback, FastifyRequest, FastifyInstance } from 'fastify';
|
1
|
+
import { FastifyPluginAsync, FastifyPluginOptions, FastifyPluginCallback, FastifyRequest, FastifyInstance } from 'fastify';
|
2
2
|
import { z } from 'zod';
|
3
3
|
import { BaseApi, Api } from '@myxtra/api';
|
4
4
|
|
@@ -8,7 +8,7 @@ declare const MOCKED_JWT_PAYLOAD: string;
|
|
8
8
|
declare const MOCKED_JWT_SIGNATURE: string;
|
9
9
|
declare const MOCKED_BEARER_TOKEN: string;
|
10
10
|
|
11
|
-
declare const _default$1: FastifyPluginAsync<
|
11
|
+
declare const _default$1: FastifyPluginAsync<FastifyPluginOptions>;
|
12
12
|
|
13
13
|
declare const validationError: z.ZodObject<z.objectUtil.extendShape<{
|
14
14
|
url: z.ZodString;
|
@@ -67,13 +67,10 @@ declare const validationError: z.ZodObject<z.objectUtil.extendShape<{
|
|
67
67
|
status: number;
|
68
68
|
name: string;
|
69
69
|
}>;
|
70
|
-
declare const _default: FastifyPluginCallback<
|
70
|
+
declare const _default: FastifyPluginCallback<FastifyPluginOptions>;
|
71
71
|
|
72
72
|
declare const createApi: <T extends BaseApi>(Api: Api<T>, request: FastifyRequest) => T;
|
73
73
|
|
74
|
-
type Language = 'nl' | 'fr';
|
75
|
-
declare const getLanguage: (acceptLanguage?: string) => Language;
|
76
|
-
|
77
74
|
declare const DEFAULT_SPEC_FILE_URL = "../.azure/apim/swagger.json";
|
78
75
|
declare const generateSwagger: (app: FastifyInstance, specFile: URL) => void;
|
79
76
|
|
@@ -86,4 +83,4 @@ declare const getTechnicalContext: (request: FastifyRequest) => {
|
|
86
83
|
};
|
87
84
|
};
|
88
85
|
|
89
|
-
export { DEFAULT_SPEC_FILE_URL, MOCKED_BEARER_TOKEN, MOCKED_JWT_HEADER, MOCKED_JWT_NAME, MOCKED_JWT_PAYLOAD, MOCKED_JWT_SIGNATURE, createApi, generateSwagger,
|
86
|
+
export { DEFAULT_SPEC_FILE_URL, MOCKED_BEARER_TOKEN, MOCKED_JWT_HEADER, MOCKED_JWT_NAME, MOCKED_JWT_PAYLOAD, MOCKED_JWT_SIGNATURE, createApi, generateSwagger, getTechnicalContext, _default$1 as swagger, validationError, _default as zod };
|
package/dist/index.mjs
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
1
2
|
var __create = Object.create;
|
2
3
|
var __defProp = Object.defineProperty;
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
-
var
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
10
|
+
}) : x)(function(x) {
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
13
|
+
});
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
8
15
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
9
16
|
};
|
10
17
|
var __copyProps = (to, from, except, desc) => {
|
@@ -24,6 +31,92 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
24
31
|
mod
|
25
32
|
));
|
26
33
|
|
34
|
+
// ../../node_modules/@fastify/error/index.js
|
35
|
+
var require_error = __commonJS({
|
36
|
+
"../../node_modules/@fastify/error/index.js"(exports, module) {
|
37
|
+
"use strict";
|
38
|
+
var { format } = __require("node:util");
|
39
|
+
function toString() {
|
40
|
+
return `${this.name} [${this.code}]: ${this.message}`;
|
41
|
+
}
|
42
|
+
function createError(code, message, statusCode = 500, Base = Error) {
|
43
|
+
if (!code) throw new Error("Fastify error code must not be empty");
|
44
|
+
if (!message) throw new Error("Fastify error message must not be empty");
|
45
|
+
code = code.toUpperCase();
|
46
|
+
!statusCode && (statusCode = void 0);
|
47
|
+
function FastifyError(...args) {
|
48
|
+
if (!new.target) {
|
49
|
+
return new FastifyError(...args);
|
50
|
+
}
|
51
|
+
this.code = code;
|
52
|
+
this.name = "FastifyError";
|
53
|
+
this.statusCode = statusCode;
|
54
|
+
const lastElement = args.length - 1;
|
55
|
+
if (lastElement !== -1 && args[lastElement] && typeof args[lastElement] === "object" && "cause" in args[lastElement]) {
|
56
|
+
this.cause = args.pop().cause;
|
57
|
+
}
|
58
|
+
this.message = format(message, ...args);
|
59
|
+
Error.stackTraceLimit !== 0 && Error.captureStackTrace(this, FastifyError);
|
60
|
+
}
|
61
|
+
FastifyError.prototype = Object.create(Base.prototype, {
|
62
|
+
constructor: {
|
63
|
+
value: FastifyError,
|
64
|
+
enumerable: false,
|
65
|
+
writable: true,
|
66
|
+
configurable: true
|
67
|
+
}
|
68
|
+
});
|
69
|
+
FastifyError.prototype[Symbol.toStringTag] = "Error";
|
70
|
+
FastifyError.prototype.toString = toString;
|
71
|
+
return FastifyError;
|
72
|
+
}
|
73
|
+
module.exports = createError;
|
74
|
+
module.exports.default = createError;
|
75
|
+
module.exports.createError = createError;
|
76
|
+
}
|
77
|
+
});
|
78
|
+
|
79
|
+
// ../../node_modules/fastify-type-provider-zod/dist/src/errors.js
|
80
|
+
var require_errors = __commonJS({
|
81
|
+
"../../node_modules/fastify-type-provider-zod/dist/src/errors.js"(exports) {
|
82
|
+
"use strict";
|
83
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
84
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
85
|
+
};
|
86
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
87
|
+
exports.createValidationError = exports.hasZodFastifySchemaValidationErrors = exports.InvalidSchemaError = exports.ResponseSerializationError = void 0;
|
88
|
+
exports.isResponseSerializationError = isResponseSerializationError;
|
89
|
+
var error_1 = __importDefault(require_error());
|
90
|
+
var ResponseSerializationError = class extends (0, error_1.default)("FST_ERR_RESPONSE_SERIALIZATION", "Response doesn't match the schema", 500) {
|
91
|
+
constructor(method, url, options) {
|
92
|
+
super({ cause: options.cause });
|
93
|
+
this.method = method;
|
94
|
+
this.url = url;
|
95
|
+
}
|
96
|
+
};
|
97
|
+
exports.ResponseSerializationError = ResponseSerializationError;
|
98
|
+
function isResponseSerializationError(value) {
|
99
|
+
return "method" in value;
|
100
|
+
}
|
101
|
+
exports.InvalidSchemaError = (0, error_1.default)("FST_ERR_INVALID_SCHEMA", "Invalid schema passed: %s", 500);
|
102
|
+
var ZodFastifySchemaValidationErrorSymbol = Symbol.for("ZodFastifySchemaValidationError");
|
103
|
+
var isZodFastifySchemaValidationError = (error) => typeof error === "object" && error !== null && ZodFastifySchemaValidationErrorSymbol in error && error[ZodFastifySchemaValidationErrorSymbol] === true;
|
104
|
+
var hasZodFastifySchemaValidationErrors2 = (error) => typeof error === "object" && error !== null && "validation" in error && Array.isArray(error.validation) && error.validation.length > 0 && isZodFastifySchemaValidationError(error.validation[0]);
|
105
|
+
exports.hasZodFastifySchemaValidationErrors = hasZodFastifySchemaValidationErrors2;
|
106
|
+
var createValidationError = (error) => error.errors.map((issue) => ({
|
107
|
+
[ZodFastifySchemaValidationErrorSymbol]: true,
|
108
|
+
keyword: issue.code,
|
109
|
+
instancePath: `/${issue.path.join("/")}`,
|
110
|
+
schemaPath: `#/${issue.path.join("/")}/${issue.code}`,
|
111
|
+
params: {
|
112
|
+
issue
|
113
|
+
},
|
114
|
+
message: issue.message
|
115
|
+
}));
|
116
|
+
exports.createValidationError = createValidationError;
|
117
|
+
}
|
118
|
+
});
|
119
|
+
|
27
120
|
// ../../node_modules/zod-to-json-schema/dist/cjs/Options.js
|
28
121
|
var require_Options = __commonJS({
|
29
122
|
"../../node_modules/zod-to-json-schema/dist/cjs/Options.js"(exports) {
|
@@ -495,7 +588,7 @@ var require_en = __commonJS({
|
|
495
588
|
});
|
496
589
|
|
497
590
|
// ../../node_modules/zod/lib/errors.js
|
498
|
-
var
|
591
|
+
var require_errors2 = __commonJS({
|
499
592
|
"../../node_modules/zod/lib/errors.js"(exports) {
|
500
593
|
"use strict";
|
501
594
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
@@ -526,7 +619,7 @@ var require_parseUtil = __commonJS({
|
|
526
619
|
};
|
527
620
|
Object.defineProperty(exports, "__esModule", { value: true });
|
528
621
|
exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
|
529
|
-
var errors_1 =
|
622
|
+
var errors_1 = require_errors2();
|
530
623
|
var en_1 = __importDefault(require_en());
|
531
624
|
var makeIssue2 = (params) => {
|
532
625
|
const { data, path, errorMaps, issueData } = params;
|
@@ -687,7 +780,7 @@ var require_types = __commonJS({
|
|
687
780
|
Object.defineProperty(exports, "__esModule", { value: true });
|
688
781
|
exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.datetimeRegex = exports.ZodType = void 0;
|
689
782
|
exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = exports.date = void 0;
|
690
|
-
var errors_1 =
|
783
|
+
var errors_1 = require_errors2();
|
691
784
|
var errorUtil_1 = require_errorUtil();
|
692
785
|
var parseUtil_1 = require_parseUtil();
|
693
786
|
var util_1 = require_util();
|
@@ -4115,7 +4208,7 @@ var require_external = __commonJS({
|
|
4115
4208
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
4116
4209
|
};
|
4117
4210
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4118
|
-
__exportStar(
|
4211
|
+
__exportStar(require_errors2(), exports);
|
4119
4212
|
__exportStar(require_parseUtil(), exports);
|
4120
4213
|
__exportStar(require_typeAliases(), exports);
|
4121
4214
|
__exportStar(require_util(), exports);
|
@@ -4189,7 +4282,7 @@ var require_array = __commonJS({
|
|
4189
4282
|
const res = {
|
4190
4283
|
type: "array"
|
4191
4284
|
};
|
4192
|
-
if (def.type?._def?.typeName !== zod_1.ZodFirstPartyTypeKind.ZodAny) {
|
4285
|
+
if (def.type?._def && def.type?._def?.typeName !== zod_1.ZodFirstPartyTypeKind.ZodAny) {
|
4193
4286
|
res.items = (0, parseDef_js_1.parseDef)(def.type._def, {
|
4194
4287
|
...refs,
|
4195
4288
|
currentPath: [...refs.currentPath, "items"]
|
@@ -4510,6 +4603,7 @@ var require_string = __commonJS({
|
|
4510
4603
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4511
4604
|
exports.parseStringDef = exports.zodPatterns = void 0;
|
4512
4605
|
var errorMessages_js_1 = require_errorMessages();
|
4606
|
+
var emojiRegex2;
|
4513
4607
|
exports.zodPatterns = {
|
4514
4608
|
/**
|
4515
4609
|
* `c` was changed to `[cC]` to replicate /i flag
|
@@ -4523,8 +4617,21 @@ var require_string = __commonJS({
|
|
4523
4617
|
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
4524
4618
|
/**
|
4525
4619
|
* Constructed a valid Unicode RegExp
|
4620
|
+
*
|
4621
|
+
* Lazily instantiate since this type of regex isn't supported
|
4622
|
+
* in all envs (e.g. React Native).
|
4623
|
+
*
|
4624
|
+
* See:
|
4625
|
+
* https://github.com/colinhacks/zod/issues/2433
|
4626
|
+
* Fix in Zod:
|
4627
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
4526
4628
|
*/
|
4527
|
-
emoji:
|
4629
|
+
emoji: () => {
|
4630
|
+
if (emojiRegex2 === void 0) {
|
4631
|
+
emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
4632
|
+
}
|
4633
|
+
return emojiRegex2;
|
4634
|
+
},
|
4528
4635
|
/**
|
4529
4636
|
* Unused
|
4530
4637
|
*/
|
@@ -4716,7 +4823,8 @@ var require_string = __commonJS({
|
|
4716
4823
|
(0, errorMessages_js_1.setResponseValueAndErrors)(schema, "pattern", processRegExp(regex, refs), message, refs);
|
4717
4824
|
}
|
4718
4825
|
};
|
4719
|
-
var processRegExp = (
|
4826
|
+
var processRegExp = (regexOrFunction, refs) => {
|
4827
|
+
const regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction;
|
4720
4828
|
if (!refs.applyRegexFlags || !regex.flags)
|
4721
4829
|
return regex.source;
|
4722
4830
|
const flags = {
|
@@ -4802,6 +4910,7 @@ var require_record = __commonJS({
|
|
4802
4910
|
var zod_1 = require_lib();
|
4803
4911
|
var parseDef_js_1 = require_parseDef();
|
4804
4912
|
var string_js_1 = require_string();
|
4913
|
+
var branded_js_1 = require_branded();
|
4805
4914
|
function parseRecordDef(def, refs) {
|
4806
4915
|
if (refs.target === "openApi3" && def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodEnum) {
|
4807
4916
|
return {
|
@@ -4828,7 +4937,7 @@ var require_record = __commonJS({
|
|
4828
4937
|
return schema;
|
4829
4938
|
}
|
4830
4939
|
if (def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
4831
|
-
const keyType =
|
4940
|
+
const { type, ...keyType } = (0, string_js_1.parseStringDef)(def.keyType._def, refs);
|
4832
4941
|
return {
|
4833
4942
|
...schema,
|
4834
4943
|
propertyNames: keyType
|
@@ -4840,6 +4949,12 @@ var require_record = __commonJS({
|
|
4840
4949
|
enum: def.keyType._def.values
|
4841
4950
|
}
|
4842
4951
|
};
|
4952
|
+
} else if (def.keyType?._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === zod_1.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
4953
|
+
const { type, ...keyType } = (0, branded_js_1.parseBrandedDef)(def.keyType._def, refs);
|
4954
|
+
return {
|
4955
|
+
...schema,
|
4956
|
+
propertyNames: keyType
|
4957
|
+
};
|
4843
4958
|
}
|
4844
4959
|
return schema;
|
4845
4960
|
}
|
@@ -5119,7 +5234,7 @@ var require_object = __commonJS({
|
|
5119
5234
|
"../../node_modules/zod-to-json-schema/dist/cjs/parsers/object.js"(exports) {
|
5120
5235
|
"use strict";
|
5121
5236
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5122
|
-
exports.parseObjectDef =
|
5237
|
+
exports.parseObjectDef = void 0;
|
5123
5238
|
var parseDef_js_1 = require_parseDef();
|
5124
5239
|
function decideAdditionalProperties(def, refs) {
|
5125
5240
|
if (refs.removeAdditionalStrategy === "strict") {
|
@@ -5134,57 +5249,6 @@ var require_object = __commonJS({
|
|
5134
5249
|
}) ?? true;
|
5135
5250
|
}
|
5136
5251
|
}
|
5137
|
-
function parseObjectDefX(def, refs) {
|
5138
|
-
Object.keys(def.shape()).reduce((schema, key) => {
|
5139
|
-
let prop = def.shape()[key];
|
5140
|
-
const isOptional = prop.isOptional();
|
5141
|
-
if (!isOptional) {
|
5142
|
-
prop = { ...prop._def.innerSchema };
|
5143
|
-
}
|
5144
|
-
const propSchema = (0, parseDef_js_1.parseDef)(prop._def, {
|
5145
|
-
...refs,
|
5146
|
-
currentPath: [...refs.currentPath, "properties", key],
|
5147
|
-
propertyPath: [...refs.currentPath, "properties", key]
|
5148
|
-
});
|
5149
|
-
if (propSchema !== void 0) {
|
5150
|
-
schema.properties[key] = propSchema;
|
5151
|
-
if (!isOptional) {
|
5152
|
-
if (!schema.required) {
|
5153
|
-
schema.required = [];
|
5154
|
-
}
|
5155
|
-
schema.required.push(key);
|
5156
|
-
}
|
5157
|
-
}
|
5158
|
-
return schema;
|
5159
|
-
}, {
|
5160
|
-
type: "object",
|
5161
|
-
properties: {},
|
5162
|
-
additionalProperties: decideAdditionalProperties(def, refs)
|
5163
|
-
});
|
5164
|
-
const result = {
|
5165
|
-
type: "object",
|
5166
|
-
...Object.entries(def.shape()).reduce((acc, [propName, propDef]) => {
|
5167
|
-
if (propDef === void 0 || propDef._def === void 0)
|
5168
|
-
return acc;
|
5169
|
-
const parsedDef = (0, parseDef_js_1.parseDef)(propDef._def, {
|
5170
|
-
...refs,
|
5171
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
5172
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
5173
|
-
});
|
5174
|
-
if (parsedDef === void 0)
|
5175
|
-
return acc;
|
5176
|
-
return {
|
5177
|
-
properties: { ...acc.properties, [propName]: parsedDef },
|
5178
|
-
required: propDef.isOptional() ? acc.required : [...acc.required, propName]
|
5179
|
-
};
|
5180
|
-
}, { properties: {}, required: [] }),
|
5181
|
-
additionalProperties: decideAdditionalProperties(def, refs)
|
5182
|
-
};
|
5183
|
-
if (!result.required.length)
|
5184
|
-
delete result.required;
|
5185
|
-
return result;
|
5186
|
-
}
|
5187
|
-
exports.parseObjectDefX = parseObjectDefX;
|
5188
5252
|
function parseObjectDef(def, refs) {
|
5189
5253
|
const result = {
|
5190
5254
|
type: "object",
|
@@ -5677,13 +5741,95 @@ var require_cjs = __commonJS({
|
|
5677
5741
|
}
|
5678
5742
|
});
|
5679
5743
|
|
5680
|
-
// ../../node_modules/fastify-type-provider-zod/dist/
|
5681
|
-
var
|
5682
|
-
"../../node_modules/fastify-type-provider-zod/dist/
|
5744
|
+
// ../../node_modules/fastify-type-provider-zod/dist/src/zod-to-json.js
|
5745
|
+
var require_zod_to_json = __commonJS({
|
5746
|
+
"../../node_modules/fastify-type-provider-zod/dist/src/zod-to-json.js"(exports) {
|
5683
5747
|
"use strict";
|
5684
5748
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5685
|
-
exports.
|
5749
|
+
exports.convertZodToJsonSchema = void 0;
|
5686
5750
|
var zod_to_json_schema_1 = require_cjs();
|
5751
|
+
var zodToJsonSchemaOptions = {
|
5752
|
+
target: "openApi3",
|
5753
|
+
$refStrategy: "none"
|
5754
|
+
};
|
5755
|
+
var convertZodToJsonSchema = (zodSchema) => {
|
5756
|
+
return (0, zod_to_json_schema_1.zodToJsonSchema)(zodSchema, zodToJsonSchemaOptions);
|
5757
|
+
};
|
5758
|
+
exports.convertZodToJsonSchema = convertZodToJsonSchema;
|
5759
|
+
}
|
5760
|
+
});
|
5761
|
+
|
5762
|
+
// ../../node_modules/fastify-type-provider-zod/dist/src/ref.js
|
5763
|
+
var require_ref = __commonJS({
|
5764
|
+
"../../node_modules/fastify-type-provider-zod/dist/src/ref.js"(exports) {
|
5765
|
+
"use strict";
|
5766
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5767
|
+
exports.resolveRefs = void 0;
|
5768
|
+
var zod_to_json_1 = require_zod_to_json();
|
5769
|
+
var createComponentMap = (schemas) => {
|
5770
|
+
const map = /* @__PURE__ */ new Map();
|
5771
|
+
for (const [key, value] of Object.entries(schemas)) {
|
5772
|
+
map.set(JSON.stringify(value), key);
|
5773
|
+
}
|
5774
|
+
return map;
|
5775
|
+
};
|
5776
|
+
var createComponentReplacer = (componentMapVK, schemasObject) => (
|
5777
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5778
|
+
function componentReplacer(key, value) {
|
5779
|
+
if (typeof value !== "object")
|
5780
|
+
return value;
|
5781
|
+
if (this === schemasObject)
|
5782
|
+
return value;
|
5783
|
+
const stringifiedValue = JSON.stringify(value);
|
5784
|
+
if (componentMapVK.has(stringifiedValue))
|
5785
|
+
return { $ref: `#/components/schemas/${componentMapVK.get(stringifiedValue)}` };
|
5786
|
+
if (value.nullable === true) {
|
5787
|
+
const nonNullableValue = { ...value };
|
5788
|
+
delete nonNullableValue.nullable;
|
5789
|
+
const stringifiedNonNullableValue = JSON.stringify(nonNullableValue);
|
5790
|
+
if (componentMapVK.has(stringifiedNonNullableValue))
|
5791
|
+
return {
|
5792
|
+
anyOf: [
|
5793
|
+
{ $ref: `#/components/schemas/${componentMapVK.get(stringifiedNonNullableValue)}` }
|
5794
|
+
],
|
5795
|
+
nullable: true
|
5796
|
+
};
|
5797
|
+
}
|
5798
|
+
return value;
|
5799
|
+
}
|
5800
|
+
);
|
5801
|
+
var resolveRefs = (openapiObject, zodSchemas) => {
|
5802
|
+
const schemas = {};
|
5803
|
+
for (const key in zodSchemas) {
|
5804
|
+
schemas[key] = (0, zod_to_json_1.convertZodToJsonSchema)(zodSchemas[key]);
|
5805
|
+
}
|
5806
|
+
const document = {
|
5807
|
+
...openapiObject,
|
5808
|
+
components: {
|
5809
|
+
...openapiObject.components,
|
5810
|
+
schemas: {
|
5811
|
+
...openapiObject.components?.schemas,
|
5812
|
+
...schemas
|
5813
|
+
}
|
5814
|
+
}
|
5815
|
+
};
|
5816
|
+
const componentMapVK = createComponentMap(schemas);
|
5817
|
+
const componentReplacer = createComponentReplacer(componentMapVK, document.components.schemas);
|
5818
|
+
return JSON.parse(JSON.stringify(document, componentReplacer));
|
5819
|
+
};
|
5820
|
+
exports.resolveRefs = resolveRefs;
|
5821
|
+
}
|
5822
|
+
});
|
5823
|
+
|
5824
|
+
// ../../node_modules/fastify-type-provider-zod/dist/src/core.js
|
5825
|
+
var require_core = __commonJS({
|
5826
|
+
"../../node_modules/fastify-type-provider-zod/dist/src/core.js"(exports) {
|
5827
|
+
"use strict";
|
5828
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5829
|
+
exports.serializerCompiler = exports.createSerializerCompiler = exports.validatorCompiler = exports.createJsonSchemaTransformObject = exports.jsonSchemaTransform = exports.createJsonSchemaTransform = void 0;
|
5830
|
+
var errors_1 = require_errors();
|
5831
|
+
var ref_1 = require_ref();
|
5832
|
+
var zod_to_json_1 = require_zod_to_json();
|
5687
5833
|
var defaultSkipList = [
|
5688
5834
|
"/documentation/",
|
5689
5835
|
"/documentation/initOAuth",
|
@@ -5693,10 +5839,6 @@ var require_dist = __commonJS({
|
|
5693
5839
|
"/documentation/*",
|
5694
5840
|
"/documentation/static/*"
|
5695
5841
|
];
|
5696
|
-
var zodToJsonSchemaOptions = {
|
5697
|
-
target: "openApi3",
|
5698
|
-
$refStrategy: "none"
|
5699
|
-
};
|
5700
5842
|
var createJsonSchemaTransform = ({ skipList }) => {
|
5701
5843
|
return ({ schema, url }) => {
|
5702
5844
|
if (!schema) {
|
@@ -5715,18 +5857,14 @@ var require_dist = __commonJS({
|
|
5715
5857
|
for (const prop in zodSchemas) {
|
5716
5858
|
const zodSchema = zodSchemas[prop];
|
5717
5859
|
if (zodSchema) {
|
5718
|
-
transformed[prop] = (0,
|
5860
|
+
transformed[prop] = (0, zod_to_json_1.convertZodToJsonSchema)(zodSchema);
|
5719
5861
|
}
|
5720
5862
|
}
|
5721
5863
|
if (response) {
|
5722
5864
|
transformed.response = {};
|
5723
5865
|
for (const prop in response) {
|
5724
5866
|
const schema2 = resolveSchema(response[prop]);
|
5725
|
-
const transformedResponse = (0,
|
5726
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5727
|
-
schema2,
|
5728
|
-
zodToJsonSchemaOptions
|
5729
|
-
);
|
5867
|
+
const transformedResponse = (0, zod_to_json_1.convertZodToJsonSchema)(schema2);
|
5730
5868
|
transformed.response[prop] = transformedResponse;
|
5731
5869
|
}
|
5732
5870
|
}
|
@@ -5743,51 +5881,87 @@ var require_dist = __commonJS({
|
|
5743
5881
|
exports.jsonSchemaTransform = (0, exports.createJsonSchemaTransform)({
|
5744
5882
|
skipList: defaultSkipList
|
5745
5883
|
});
|
5746
|
-
var
|
5747
|
-
|
5748
|
-
|
5749
|
-
|
5750
|
-
return { value: schema.parse(data) };
|
5751
|
-
} catch (error) {
|
5752
|
-
return { error };
|
5753
|
-
}
|
5884
|
+
var createJsonSchemaTransformObject = ({ schemas }) => (input) => {
|
5885
|
+
if ("swaggerObject" in input) {
|
5886
|
+
console.warn("This package currently does not support component references for Swagger 2.0");
|
5887
|
+
return input.swaggerObject;
|
5754
5888
|
}
|
5755
|
-
|
5889
|
+
return (0, ref_1.resolveRefs)(input.openapiObject, schemas);
|
5890
|
+
};
|
5891
|
+
exports.createJsonSchemaTransformObject = createJsonSchemaTransformObject;
|
5892
|
+
var validatorCompiler2 = ({ schema }) => (data) => {
|
5893
|
+
const result = schema.safeParse(data);
|
5894
|
+
if (result.error) {
|
5895
|
+
return { error: (0, errors_1.createValidationError)(result.error) };
|
5896
|
+
}
|
5897
|
+
return { value: result.data };
|
5898
|
+
};
|
5756
5899
|
exports.validatorCompiler = validatorCompiler2;
|
5757
|
-
function hasOwnProperty(obj, prop) {
|
5758
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
5759
|
-
}
|
5760
5900
|
function resolveSchema(maybeSchema) {
|
5761
|
-
if (
|
5901
|
+
if ("safeParse" in maybeSchema) {
|
5762
5902
|
return maybeSchema;
|
5763
5903
|
}
|
5764
|
-
if (
|
5904
|
+
if ("properties" in maybeSchema) {
|
5765
5905
|
return maybeSchema.properties;
|
5766
5906
|
}
|
5767
|
-
throw new
|
5907
|
+
throw new errors_1.InvalidSchemaError(JSON.stringify(maybeSchema));
|
5768
5908
|
}
|
5769
|
-
var
|
5770
|
-
constructor(validationResult) {
|
5771
|
-
super("Response doesn't match the schema");
|
5772
|
-
this.name = "ResponseValidationError";
|
5773
|
-
this.details = validationResult.error;
|
5774
|
-
}
|
5775
|
-
};
|
5776
|
-
exports.ResponseValidationError = ResponseValidationError;
|
5777
|
-
var serializerCompiler2 = ({ schema: maybeSchema }) => (data) => {
|
5909
|
+
var createSerializerCompiler = (options) => ({ schema: maybeSchema, method, url }) => (data) => {
|
5778
5910
|
const schema = resolveSchema(maybeSchema);
|
5779
5911
|
const result = schema.safeParse(data);
|
5780
|
-
if (result.
|
5781
|
-
|
5912
|
+
if (result.error) {
|
5913
|
+
throw new errors_1.ResponseSerializationError(method, url, { cause: result.error });
|
5782
5914
|
}
|
5783
|
-
|
5915
|
+
return JSON.stringify(result.data, options?.replacer);
|
5784
5916
|
};
|
5785
|
-
exports.
|
5917
|
+
exports.createSerializerCompiler = createSerializerCompiler;
|
5918
|
+
exports.serializerCompiler = (0, exports.createSerializerCompiler)({});
|
5919
|
+
}
|
5920
|
+
});
|
5921
|
+
|
5922
|
+
// ../../node_modules/fastify-type-provider-zod/dist/index.js
|
5923
|
+
var require_dist = __commonJS({
|
5924
|
+
"../../node_modules/fastify-type-provider-zod/dist/index.js"(exports) {
|
5925
|
+
"use strict";
|
5926
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5927
|
+
exports.isResponseSerializationError = exports.hasZodFastifySchemaValidationErrors = exports.InvalidSchemaError = exports.ResponseSerializationError = exports.createSerializerCompiler = exports.validatorCompiler = exports.serializerCompiler = exports.createJsonSchemaTransformObject = exports.createJsonSchemaTransform = exports.jsonSchemaTransform = void 0;
|
5928
|
+
var core_1 = require_core();
|
5929
|
+
Object.defineProperty(exports, "jsonSchemaTransform", { enumerable: true, get: function() {
|
5930
|
+
return core_1.jsonSchemaTransform;
|
5931
|
+
} });
|
5932
|
+
Object.defineProperty(exports, "createJsonSchemaTransform", { enumerable: true, get: function() {
|
5933
|
+
return core_1.createJsonSchemaTransform;
|
5934
|
+
} });
|
5935
|
+
Object.defineProperty(exports, "createJsonSchemaTransformObject", { enumerable: true, get: function() {
|
5936
|
+
return core_1.createJsonSchemaTransformObject;
|
5937
|
+
} });
|
5938
|
+
Object.defineProperty(exports, "serializerCompiler", { enumerable: true, get: function() {
|
5939
|
+
return core_1.serializerCompiler;
|
5940
|
+
} });
|
5941
|
+
Object.defineProperty(exports, "validatorCompiler", { enumerable: true, get: function() {
|
5942
|
+
return core_1.validatorCompiler;
|
5943
|
+
} });
|
5944
|
+
Object.defineProperty(exports, "createSerializerCompiler", { enumerable: true, get: function() {
|
5945
|
+
return core_1.createSerializerCompiler;
|
5946
|
+
} });
|
5947
|
+
var errors_1 = require_errors();
|
5948
|
+
Object.defineProperty(exports, "ResponseSerializationError", { enumerable: true, get: function() {
|
5949
|
+
return errors_1.ResponseSerializationError;
|
5950
|
+
} });
|
5951
|
+
Object.defineProperty(exports, "InvalidSchemaError", { enumerable: true, get: function() {
|
5952
|
+
return errors_1.InvalidSchemaError;
|
5953
|
+
} });
|
5954
|
+
Object.defineProperty(exports, "hasZodFastifySchemaValidationErrors", { enumerable: true, get: function() {
|
5955
|
+
return errors_1.hasZodFastifySchemaValidationErrors;
|
5956
|
+
} });
|
5957
|
+
Object.defineProperty(exports, "isResponseSerializationError", { enumerable: true, get: function() {
|
5958
|
+
return errors_1.isResponseSerializationError;
|
5959
|
+
} });
|
5786
5960
|
}
|
5787
5961
|
});
|
5788
5962
|
|
5789
5963
|
// src/mocks/jwt.ts
|
5790
|
-
import { createHmac } from "crypto";
|
5964
|
+
import { createHmac } from "node:crypto";
|
5791
5965
|
var MOCKED_JWT_NAME = "toolkit@systemtest.dcs";
|
5792
5966
|
var MOCKED_JWT_HEADER = btoa(JSON.stringify({ alg: "HS256" }));
|
5793
5967
|
var MOCKED_JWT_PAYLOAD = btoa(JSON.stringify({ name: MOCKED_JWT_NAME }));
|
@@ -9751,8 +9925,18 @@ var zod = (app, options, done) => {
|
|
9751
9925
|
app.setValidatorCompiler(import_fastify_type_provider_zod2.validatorCompiler);
|
9752
9926
|
app.setSerializerCompiler(import_fastify_type_provider_zod2.serializerCompiler);
|
9753
9927
|
app.setErrorHandler((error, request, reply) => {
|
9754
|
-
if (
|
9755
|
-
const problemJson =
|
9928
|
+
if ((0, import_fastify_type_provider_zod2.hasZodFastifySchemaValidationErrors)(error)) {
|
9929
|
+
const problemJson = {
|
9930
|
+
fieldErrors: {},
|
9931
|
+
formErrors: []
|
9932
|
+
};
|
9933
|
+
error.validation.map((error2) => error2.params.issue).forEach(({ path, message }) => {
|
9934
|
+
if (path.length > 0) {
|
9935
|
+
problemJson.fieldErrors[path.at(-1)] = [message];
|
9936
|
+
} else {
|
9937
|
+
problemJson.formErrors.push(message);
|
9938
|
+
}
|
9939
|
+
});
|
9756
9940
|
return reply.status(400).send({
|
9757
9941
|
url: request.url,
|
9758
9942
|
name: "BAD_REQUEST",
|
@@ -9772,18 +9956,11 @@ var zod_default = fp2(zod);
|
|
9772
9956
|
import "@myxtra/api";
|
9773
9957
|
import config from "config";
|
9774
9958
|
import "fastify";
|
9775
|
-
|
9776
|
-
// src/utils/language.ts
|
9777
|
-
var getLanguage = (acceptLanguage) => {
|
9778
|
-
if (acceptLanguage !== "nl" && acceptLanguage !== "fr") {
|
9779
|
-
return "nl";
|
9780
|
-
}
|
9781
|
-
return acceptLanguage;
|
9782
|
-
};
|
9783
|
-
|
9784
|
-
// src/utils/api.ts
|
9785
9959
|
var createApi = (Api, request) => {
|
9786
|
-
const acceptLanguage =
|
9960
|
+
const acceptLanguage = request.headers["accept-language"];
|
9961
|
+
if (!acceptLanguage) {
|
9962
|
+
throw new Error("'accept-language' header is missing");
|
9963
|
+
}
|
9787
9964
|
const authorization = request.headers.authorization ?? "";
|
9788
9965
|
return new Api({ acceptLanguage, authorization, config });
|
9789
9966
|
};
|
@@ -9827,7 +10004,6 @@ export {
|
|
9827
10004
|
MOCKED_JWT_SIGNATURE,
|
9828
10005
|
createApi,
|
9829
10006
|
generateSwagger,
|
9830
|
-
getLanguage,
|
9831
10007
|
getTechnicalContext,
|
9832
10008
|
swagger_default as swagger,
|
9833
10009
|
validationError,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@myxtra/microservice",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.18.0-alpha.0",
|
4
4
|
"main": "./dist/index.mjs",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"publishConfig": {
|
@@ -20,13 +20,13 @@
|
|
20
20
|
"typecheck": "tsc --noEmit"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"@myxtra/api": "1.
|
23
|
+
"@myxtra/api": "1.18.0-alpha.0"
|
24
24
|
},
|
25
25
|
"devDependencies": {
|
26
|
-
"@myxtra/eslint-config": "1.
|
26
|
+
"@myxtra/eslint-config": "1.20.0",
|
27
27
|
"@tsconfig/node18": "^18.2.4",
|
28
28
|
"eslint": "^8.57.1",
|
29
|
-
"fastify-type-provider-zod": "^
|
29
|
+
"fastify-type-provider-zod": "^4.0.1",
|
30
30
|
"prettier": "^3.3.3",
|
31
31
|
"tsup": "^8.3.0",
|
32
32
|
"typescript": "^5.6.2"
|