@event-driven-io/emmett 0.34.0 → 0.35.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4E7QLAH5.js → chunk-BQYVGGNE.js} +11 -1
- package/dist/chunk-BQYVGGNE.js.map +1 -0
- package/dist/{chunk-WM5VB4U5.cjs → chunk-WIOXGPNN.cjs} +12 -2
- package/dist/chunk-WIOXGPNN.cjs.map +1 -0
- package/dist/cli.cjs +7 -7
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-BMuDF2Bm.d.cts → index-CKESCXxJ.d.cts} +4 -1
- package/dist/{index-BMuDF2Bm.d.ts → index-CKESCXxJ.d.ts} +4 -1
- package/dist/index.cjs +244 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -16
- package/dist/index.d.ts +77 -16
- package/dist/index.js +223 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4E7QLAH5.js.map +0 -1
- package/dist/chunk-WM5VB4U5.cjs.map +0 -1
|
@@ -56,6 +56,15 @@ var ConcurrencyError = class _ConcurrencyError extends EmmettError {
|
|
|
56
56
|
Object.setPrototypeOf(this, _ConcurrencyError.prototype);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
+
var ConcurrencyInMemoryDatabaseError = class _ConcurrencyInMemoryDatabaseError extends EmmettError {
|
|
60
|
+
constructor(message) {
|
|
61
|
+
super({
|
|
62
|
+
errorCode: 412,
|
|
63
|
+
message: message ?? `Expected document state does not match current one!`
|
|
64
|
+
});
|
|
65
|
+
Object.setPrototypeOf(this, _ConcurrencyInMemoryDatabaseError.prototype);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
59
68
|
var ValidationError = class _ValidationError extends EmmettError {
|
|
60
69
|
constructor(message) {
|
|
61
70
|
super({
|
|
@@ -123,8 +132,9 @@ export {
|
|
|
123
132
|
isErrorConstructor,
|
|
124
133
|
EmmettError,
|
|
125
134
|
ConcurrencyError,
|
|
135
|
+
ConcurrencyInMemoryDatabaseError,
|
|
126
136
|
ValidationError,
|
|
127
137
|
IllegalStateError,
|
|
128
138
|
NotFoundError
|
|
129
139
|
};
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-BQYVGGNE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config/plugins/index.ts","../src/validation/index.ts","../src/errors/index.ts","../src/validation/dates.ts"],"sourcesContent":["export type EmmettPluginConfig =\n | {\n name: string;\n register: EmmettPluginRegistration[];\n }\n | string;\n\nexport type EmmettPluginType = 'cli';\n\nexport type EmmettCliPluginRegistration = { pluginType: 'cli'; path?: string };\n\nexport type EmmettPluginRegistration = EmmettCliPluginRegistration;\n\nexport type EmmettCliCommand = {\n addCommand<CliCommand>(command: CliCommand): CliCommand;\n};\n\nexport type EmmettCliPlugin = {\n pluginType: 'cli';\n name: string;\n registerCommands: (program: EmmettCliCommand) => Promise<void> | void;\n};\n\nexport type EmmettPlugin = EmmettCliPlugin;\n\nexport const isPluginConfig = (\n plugin: Partial<EmmettPluginConfig> | string | undefined,\n): plugin is EmmettPluginConfig =>\n plugin !== undefined &&\n (typeof plugin === 'string' ||\n ('name' in plugin &&\n plugin.name !== undefined &&\n typeof plugin.name === 'string'));\n","import { ValidationError } from '../errors';\n\nexport const enum ValidationErrors {\n NOT_A_NONEMPTY_STRING = 'NOT_A_NONEMPTY_STRING',\n NOT_A_POSITIVE_NUMBER = 'NOT_A_POSITIVE_NUMBER',\n NOT_AN_UNSIGNED_BIGINT = 'NOT_AN_UNSIGNED_BIGINT',\n}\n\nexport const isNumber = (val: unknown): val is number =>\n typeof val === 'number' && val === val;\n\nexport const isString = (val: unknown): val is string =>\n typeof val === 'string';\n\nexport const assertNotEmptyString = (value: unknown): string => {\n if (!isString(value) || value.length === 0) {\n throw new ValidationError(ValidationErrors.NOT_A_NONEMPTY_STRING);\n }\n return value;\n};\n\nexport const assertPositiveNumber = (value: unknown): number => {\n if (!isNumber(value) || value <= 0) {\n throw new ValidationError(ValidationErrors.NOT_A_POSITIVE_NUMBER);\n }\n return value;\n};\n\nexport const assertUnsignedBigInt = (value: string): bigint => {\n const number = BigInt(value);\n if (number < 0) {\n throw new ValidationError(ValidationErrors.NOT_AN_UNSIGNED_BIGINT);\n }\n return number;\n};\n\nexport * from './dates';\n","import { isNumber, isString } from '../validation';\n\nexport type ErrorConstructor<ErrorType extends Error> = new (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: any[]\n) => ErrorType;\n\nexport const isErrorConstructor = <ErrorType extends Error>(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n expect: Function,\n): expect is ErrorConstructor<ErrorType> => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n typeof expect === 'function' &&\n expect.prototype &&\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect.prototype.constructor === expect\n );\n};\n\nexport class EmmettError extends Error {\n public errorCode: number;\n\n constructor(\n options?: { errorCode: number; message?: string } | string | number,\n ) {\n const errorCode =\n options && typeof options === 'object' && 'errorCode' in options\n ? options.errorCode\n : isNumber(options)\n ? options\n : 500;\n const message =\n options && typeof options === 'object' && 'message' in options\n ? options.message\n : isString(options)\n ? options\n : `Error with status code '${errorCode}' ocurred during Emmett processing`;\n\n super(message);\n this.errorCode = errorCode;\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, EmmettError.prototype);\n }\n}\n\nexport class ConcurrencyError extends EmmettError {\n constructor(\n public current: string | undefined,\n public expected: string,\n message?: string,\n ) {\n super({\n errorCode: 412,\n message:\n message ??\n `Expected version ${expected.toString()} does not match current ${current?.toString()}`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, ConcurrencyError.prototype);\n }\n}\n\nexport class ConcurrencyInMemoryDatabaseError extends EmmettError {\n constructor(message?: string) {\n super({\n errorCode: 412,\n message: message ?? `Expected document state does not match current one!`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, ConcurrencyInMemoryDatabaseError.prototype);\n }\n}\n\nexport class ValidationError extends EmmettError {\n constructor(message?: string) {\n super({\n errorCode: 400,\n message: message ?? `Validation Error ocurred during Emmett processing`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class IllegalStateError extends EmmettError {\n constructor(message?: string) {\n super({\n errorCode: 403,\n message: message ?? `Illegal State ocurred during Emmett processing`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, IllegalStateError.prototype);\n }\n}\n\nexport class NotFoundError extends EmmettError {\n constructor(options?: { id: string; type: string; message?: string }) {\n super({\n errorCode: 404,\n message:\n options?.message ??\n (options?.id\n ? options.type\n ? `${options.type} with ${options.id} was not found during Emmett processing`\n : `State with ${options.id} was not found during Emmett processing`\n : options?.type\n ? `${options.type} was not found during Emmett processing`\n : 'State was not found during Emmett processing'),\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { ValidationError } from '../errors';\n\nexport const formatDateToUtcYYYYMMDD = (date: Date) => {\n // Use the 'en-CA' locale which formats as 'yyyy-mm-dd'\n const formatter = new Intl.DateTimeFormat('en-CA', {\n timeZone: 'UTC',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n });\n\n // Format the date\n return formatter.format(date);\n};\n\n// Function to validate 'yyyy-mm-dd' format\nexport const isValidYYYYMMDD = (dateString: string) => {\n const regex = /^\\d{4}-\\d{2}-\\d{2}$/;\n return regex.test(dateString);\n};\n\nexport const parseDateFromUtcYYYYMMDD = (dateString: string) => {\n const date = new Date(dateString + 'T00:00:00Z');\n\n if (!isValidYYYYMMDD(dateString)) {\n throw new ValidationError('Invalid date format, must be yyyy-mm-dd');\n }\n\n if (isNaN(date.getTime())) {\n throw new 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AA,EACrD;AACF;;;ACrHO,IAAM,0BAA0B,CAAC,SAAe;AAErD,QAAM,YAAY,IAAI,KAAK,eAAe,SAAS;AAAA,IACjD,UAAU;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,EACP,CAAC;AAGD,SAAO,UAAU,OAAO,IAAI;AAC9B;AAGO,IAAM,kBAAkB,CAAC,eAAuB;AACrD,QAAM,QAAQ;AACd,SAAO,MAAM,KAAK,UAAU;AAC9B;AAEO,IAAM,2BAA2B,CAAC,eAAuB;AAC9D,QAAM,OAAO,oBAAI,KAAK,aAAa,YAAY;AAE/C,MAAI,CAAC,gBAAgB,UAAU,GAAG;AAChC,UAAM,IAAI,gBAAgB,yCAAyC;AAAA,EACrE;AAEA,MAAI,MAAM,KAAK,QAAQ,CAAC,GAAG;AACzB,UAAM,IAAI,gBAAgB,qBAAqB;AAAA,EACjD;AAEA,SAAO;AACT;","names":["ValidationErrors"]}
|
|
@@ -56,6 +56,15 @@ var ConcurrencyError = class _ConcurrencyError extends EmmettError {
|
|
|
56
56
|
Object.setPrototypeOf(this, _ConcurrencyError.prototype);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
+
var ConcurrencyInMemoryDatabaseError = class _ConcurrencyInMemoryDatabaseError extends EmmettError {
|
|
60
|
+
constructor(message) {
|
|
61
|
+
super({
|
|
62
|
+
errorCode: 412,
|
|
63
|
+
message: _nullishCoalesce(message, () => ( `Expected document state does not match current one!`))
|
|
64
|
+
});
|
|
65
|
+
Object.setPrototypeOf(this, _ConcurrencyInMemoryDatabaseError.prototype);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
59
68
|
var ValidationError = class _ValidationError extends EmmettError {
|
|
60
69
|
constructor(message) {
|
|
61
70
|
super({
|
|
@@ -126,5 +135,6 @@ var parseDateFromUtcYYYYMMDD = (dateString) => {
|
|
|
126
135
|
|
|
127
136
|
|
|
128
137
|
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
|
|
139
|
+
exports.isPluginConfig = isPluginConfig; exports.formatDateToUtcYYYYMMDD = formatDateToUtcYYYYMMDD; exports.isValidYYYYMMDD = isValidYYYYMMDD; exports.parseDateFromUtcYYYYMMDD = parseDateFromUtcYYYYMMDD; exports.ValidationErrors = ValidationErrors; exports.isNumber = isNumber; exports.isString = isString; exports.assertNotEmptyString = assertNotEmptyString; exports.assertPositiveNumber = assertPositiveNumber; exports.assertUnsignedBigInt = assertUnsignedBigInt; exports.isErrorConstructor = isErrorConstructor; exports.EmmettError = EmmettError; exports.ConcurrencyError = ConcurrencyError; exports.ConcurrencyInMemoryDatabaseError = ConcurrencyInMemoryDatabaseError; exports.ValidationError = ValidationError; exports.IllegalStateError = IllegalStateError; exports.NotFoundError = NotFoundError;
|
|
140
|
+
//# sourceMappingURL=chunk-WIOXGPNN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/emmett/emmett/src/packages/emmett/dist/chunk-WIOXGPNN.cjs","../src/config/plugins/index.ts","../src/validation/index.ts","../src/errors/index.ts","../src/validation/dates.ts"],"names":["ValidationErrors"],"mappings":"AAAA;ACyBO,IAAM,eAAA,EAAiB,CAC5B,MAAA,EAAA,GAEA,OAAA,IAAW,KAAA,EAAA,GAAA,CACV,OAAO,OAAA,IAAW,SAAA,GAChB,OAAA,GAAU,OAAA,GACT,MAAA,CAAO,KAAA,IAAS,KAAA,EAAA,GAChB,OAAO,MAAA,CAAO,KAAA,IAAS,QAAA,CAAA;AD9B7B;AACA;AEDO,IAAW,iBAAA,kBAAX,CAAA,CAAWA,iBAAAA,EAAAA,GAAX;AACL,EAAAA,iBAAAA,CAAA,uBAAA,EAAA,EAAwB,uBAAA;AACxB,EAAAA,iBAAAA,CAAA,uBAAA,EAAA,EAAwB,uBAAA;AACxB,EAAAA,iBAAAA,CAAA,wBAAA,EAAA,EAAyB,wBAAA;AAHT,EAAA,OAAAA,iBAAAA;AAAA,CAAA,CAAA,CAAA,iBAAA,G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IAAA;AAAM,MAAA;AACO,MAAA;AASH,IAAA;AAIV,IAAA;AAAmD,EAAA;AAEvD;AHzBA;AACA;AI7FO;AAEL,EAAA;AAAmD,IAAA;AACvC,IAAA;AACJ,IAAA;AACC,IAAA;AACF,EAAA;AAIP,EAAA;AACF;AAGO;AACL,EAAA;AACA,EAAA;AACF;AAEO;AACL,EAAA;AAEA,EAAA;AACE,IAAA;AAAmE,EAAA;AAGrE,EAAA;AACE,IAAA;AAA+C,EAAA;AAGjD,EAAA;AACF;AJsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/emmett/emmett/src/packages/emmett/dist/chunk-WIOXGPNN.cjs","sourcesContent":[null,"export type EmmettPluginConfig =\n | {\n name: string;\n register: EmmettPluginRegistration[];\n }\n | string;\n\nexport type EmmettPluginType = 'cli';\n\nexport type EmmettCliPluginRegistration = { pluginType: 'cli'; path?: string };\n\nexport type EmmettPluginRegistration = EmmettCliPluginRegistration;\n\nexport type EmmettCliCommand = {\n addCommand<CliCommand>(command: CliCommand): CliCommand;\n};\n\nexport type EmmettCliPlugin = {\n pluginType: 'cli';\n name: string;\n registerCommands: (program: EmmettCliCommand) => Promise<void> | void;\n};\n\nexport type EmmettPlugin = EmmettCliPlugin;\n\nexport const isPluginConfig = (\n plugin: Partial<EmmettPluginConfig> | string | undefined,\n): plugin is EmmettPluginConfig =>\n plugin !== undefined &&\n (typeof plugin === 'string' ||\n ('name' in plugin &&\n plugin.name !== undefined &&\n typeof plugin.name === 'string'));\n","import { ValidationError } from '../errors';\n\nexport const enum ValidationErrors {\n NOT_A_NONEMPTY_STRING = 'NOT_A_NONEMPTY_STRING',\n NOT_A_POSITIVE_NUMBER = 'NOT_A_POSITIVE_NUMBER',\n NOT_AN_UNSIGNED_BIGINT = 'NOT_AN_UNSIGNED_BIGINT',\n}\n\nexport const isNumber = (val: unknown): val is number =>\n typeof val === 'number' && val === val;\n\nexport const isString = (val: unknown): val is string =>\n typeof val === 'string';\n\nexport const assertNotEmptyString = (value: unknown): string => {\n if (!isString(value) || value.length === 0) {\n throw new ValidationError(ValidationErrors.NOT_A_NONEMPTY_STRING);\n }\n return value;\n};\n\nexport const assertPositiveNumber = (value: unknown): number => {\n if (!isNumber(value) || value <= 0) {\n throw new ValidationError(ValidationErrors.NOT_A_POSITIVE_NUMBER);\n }\n return value;\n};\n\nexport const assertUnsignedBigInt = (value: string): bigint => {\n const number = BigInt(value);\n if (number < 0) {\n throw new ValidationError(ValidationErrors.NOT_AN_UNSIGNED_BIGINT);\n }\n return number;\n};\n\nexport * from './dates';\n","import { isNumber, isString } from '../validation';\n\nexport type ErrorConstructor<ErrorType extends Error> = new (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: any[]\n) => ErrorType;\n\nexport const isErrorConstructor = <ErrorType extends Error>(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n expect: Function,\n): expect is ErrorConstructor<ErrorType> => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n typeof expect === 'function' &&\n expect.prototype &&\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect.prototype.constructor === expect\n );\n};\n\nexport class EmmettError extends Error {\n public errorCode: number;\n\n constructor(\n options?: { errorCode: number; message?: string } | string | number,\n ) {\n const errorCode =\n options && typeof options === 'object' && 'errorCode' in options\n ? options.errorCode\n : isNumber(options)\n ? options\n : 500;\n const message =\n options && typeof options === 'object' && 'message' in options\n ? options.message\n : isString(options)\n ? options\n : `Error with status code '${errorCode}' ocurred during Emmett processing`;\n\n super(message);\n this.errorCode = errorCode;\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, EmmettError.prototype);\n }\n}\n\nexport class ConcurrencyError extends EmmettError {\n constructor(\n public current: string | undefined,\n public expected: string,\n message?: string,\n ) {\n super({\n errorCode: 412,\n message:\n message ??\n `Expected version ${expected.toString()} does not match current ${current?.toString()}`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, ConcurrencyError.prototype);\n }\n}\n\nexport class ConcurrencyInMemoryDatabaseError extends EmmettError {\n constructor(message?: string) {\n super({\n errorCode: 412,\n message: message ?? `Expected document state does not match current one!`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, ConcurrencyInMemoryDatabaseError.prototype);\n }\n}\n\nexport class ValidationError extends EmmettError {\n constructor(message?: string) {\n super({\n errorCode: 400,\n message: message ?? `Validation Error ocurred during Emmett processing`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class IllegalStateError extends EmmettError {\n constructor(message?: string) {\n super({\n errorCode: 403,\n message: message ?? `Illegal State ocurred during Emmett processing`,\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, IllegalStateError.prototype);\n }\n}\n\nexport class NotFoundError extends EmmettError {\n constructor(options?: { id: string; type: string; message?: string }) {\n super({\n errorCode: 404,\n message:\n options?.message ??\n (options?.id\n ? options.type\n ? `${options.type} with ${options.id} was not found during Emmett processing`\n : `State with ${options.id} was not found during Emmett processing`\n : options?.type\n ? `${options.type} was not found during Emmett processing`\n : 'State was not found during Emmett processing'),\n });\n\n // 👇️ because we are extending a built-in class\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { ValidationError } from '../errors';\n\nexport const formatDateToUtcYYYYMMDD = (date: Date) => {\n // Use the 'en-CA' locale which formats as 'yyyy-mm-dd'\n const formatter = new Intl.DateTimeFormat('en-CA', {\n timeZone: 'UTC',\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n });\n\n // Format the date\n return formatter.format(date);\n};\n\n// Function to validate 'yyyy-mm-dd' format\nexport const isValidYYYYMMDD = (dateString: string) => {\n const regex = /^\\d{4}-\\d{2}-\\d{2}$/;\n return regex.test(dateString);\n};\n\nexport const parseDateFromUtcYYYYMMDD = (dateString: string) => {\n const date = new Date(dateString + 'T00:00:00Z');\n\n if (!isValidYYYYMMDD(dateString)) {\n throw new ValidationError('Invalid date format, must be yyyy-mm-dd');\n }\n\n if (isNaN(date.getTime())) {\n throw new ValidationError('Invalid date format');\n }\n\n return date;\n};\n"]}
|
package/dist/cli.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkWIOXGPNNcjs = require('./chunk-WIOXGPNN.cjs');
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
var _commander = require('commander');
|
|
@@ -86,15 +86,15 @@ var importPluginsConfig = async (options) => {
|
|
|
86
86
|
try {
|
|
87
87
|
const imported = await Promise.resolve().then(() => _interopRequireWildcard(require(configPath)));
|
|
88
88
|
if (!imported.default) {
|
|
89
|
-
return new (0,
|
|
89
|
+
return new (0, _chunkWIOXGPNNcjs.EmmettError)(PluginsConfigImportError.missingDefaultExport);
|
|
90
90
|
}
|
|
91
91
|
if (!imported.default.plugins || !Array.isArray(imported.default.plugins)) {
|
|
92
|
-
return new (0,
|
|
92
|
+
return new (0, _chunkWIOXGPNNcjs.EmmettError)(
|
|
93
93
|
PluginsConfigImportError.missingPluginsPropertyExport
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
-
if (!imported.default.plugins.every(
|
|
97
|
-
return new (0,
|
|
96
|
+
if (!imported.default.plugins.every(_chunkWIOXGPNNcjs.isPluginConfig)) {
|
|
97
|
+
return new (0, _chunkWIOXGPNNcjs.EmmettError)(PluginsConfigImportError.wrongPluginStructure);
|
|
98
98
|
}
|
|
99
99
|
return { plugins: imported.default.plugins };
|
|
100
100
|
} catch (error) {
|
|
@@ -102,7 +102,7 @@ var importPluginsConfig = async (options) => {
|
|
|
102
102
|
console.warn("Didn`t find config file: " + configPath, error);
|
|
103
103
|
return { plugins: [] };
|
|
104
104
|
}
|
|
105
|
-
return new (0,
|
|
105
|
+
return new (0, _chunkWIOXGPNNcjs.EmmettError)(
|
|
106
106
|
`Error: Couldn't load file:` + error.toString()
|
|
107
107
|
);
|
|
108
108
|
}
|
|
@@ -112,7 +112,7 @@ var loadPlugins = async (options) => {
|
|
|
112
112
|
const pluginsConfig = await importPluginsConfig({
|
|
113
113
|
configPath: _optionalChain([options, 'optionalAccess', _3 => _3.configPath])
|
|
114
114
|
});
|
|
115
|
-
if (pluginsConfig instanceof
|
|
115
|
+
if (pluginsConfig instanceof _chunkWIOXGPNNcjs.EmmettError) throw pluginsConfig;
|
|
116
116
|
if (pluginsConfig.plugins.length === 0) {
|
|
117
117
|
console.log(`No extensions specified in config ${_optionalChain([options, 'optionalAccess', _4 => _4.configPath])}.`);
|
|
118
118
|
return [];
|
package/dist/cli.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import { E as EmmettPluginsConfig, a as EmmettError, b as EmmettPluginType, c as EmmettPlugin, d as EmmettCliPlugin } from './index-
|
|
3
|
+
import { E as EmmettPluginsConfig, a as EmmettError, b as EmmettPluginType, c as EmmettPlugin, d as EmmettCliPlugin } from './index-CKESCXxJ.cjs';
|
|
4
4
|
|
|
5
5
|
declare const sampleConfig: (plugins?: string[]) => string;
|
|
6
6
|
declare const generateConfigFile: (configPath: string, collectionNames: string[]) => void;
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import { E as EmmettPluginsConfig, a as EmmettError, b as EmmettPluginType, c as EmmettPlugin, d as EmmettCliPlugin } from './index-
|
|
3
|
+
import { E as EmmettPluginsConfig, a as EmmettError, b as EmmettPluginType, c as EmmettPlugin, d as EmmettCliPlugin } from './index-CKESCXxJ.js';
|
|
4
4
|
|
|
5
5
|
declare const sampleConfig: (plugins?: string[]) => string;
|
|
6
6
|
declare const generateConfigFile: (configPath: string, collectionNames: string[]) => void;
|
package/dist/cli.js
CHANGED
|
@@ -37,6 +37,9 @@ declare class ConcurrencyError extends EmmettError {
|
|
|
37
37
|
expected: string;
|
|
38
38
|
constructor(current: string | undefined, expected: string, message?: string);
|
|
39
39
|
}
|
|
40
|
+
declare class ConcurrencyInMemoryDatabaseError extends EmmettError {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
40
43
|
declare class ValidationError extends EmmettError {
|
|
41
44
|
constructor(message?: string);
|
|
42
45
|
}
|
|
@@ -51,4 +54,4 @@ declare class NotFoundError extends EmmettError {
|
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
export { ConcurrencyError as C, type EmmettPluginsConfig as E, IllegalStateError as I, NotFoundError as N, ValidationError as V, EmmettError as a, type EmmettPluginType as b, type EmmettPlugin as c, type EmmettCliPlugin as d, type ErrorConstructor as e, type EmmettPluginConfig as f, type EmmettCliPluginRegistration as g, type EmmettPluginRegistration as h, type EmmettCliCommand as i, isPluginConfig as j, isErrorConstructor as k };
|
|
57
|
+
export { ConcurrencyError as C, type EmmettPluginsConfig as E, IllegalStateError as I, NotFoundError as N, ValidationError as V, EmmettError as a, type EmmettPluginType as b, type EmmettPlugin as c, type EmmettCliPlugin as d, type ErrorConstructor as e, type EmmettPluginConfig as f, type EmmettCliPluginRegistration as g, type EmmettPluginRegistration as h, type EmmettCliCommand as i, isPluginConfig as j, isErrorConstructor as k, ConcurrencyInMemoryDatabaseError as l };
|
|
@@ -37,6 +37,9 @@ declare class ConcurrencyError extends EmmettError {
|
|
|
37
37
|
expected: string;
|
|
38
38
|
constructor(current: string | undefined, expected: string, message?: string);
|
|
39
39
|
}
|
|
40
|
+
declare class ConcurrencyInMemoryDatabaseError extends EmmettError {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
40
43
|
declare class ValidationError extends EmmettError {
|
|
41
44
|
constructor(message?: string);
|
|
42
45
|
}
|
|
@@ -51,4 +54,4 @@ declare class NotFoundError extends EmmettError {
|
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
export { ConcurrencyError as C, type EmmettPluginsConfig as E, IllegalStateError as I, NotFoundError as N, ValidationError as V, EmmettError as a, type EmmettPluginType as b, type EmmettPlugin as c, type EmmettCliPlugin as d, type ErrorConstructor as e, type EmmettPluginConfig as f, type EmmettCliPluginRegistration as g, type EmmettPluginRegistration as h, type EmmettCliCommand as i, isPluginConfig as j, isErrorConstructor as k };
|
|
57
|
+
export { ConcurrencyError as C, type EmmettPluginsConfig as E, IllegalStateError as I, NotFoundError as N, ValidationError as V, EmmettError as a, type EmmettPluginType as b, type EmmettPlugin as c, type EmmettCliPlugin as d, type ErrorConstructor as e, type EmmettPluginConfig as f, type EmmettCliPluginRegistration as g, type EmmettPluginRegistration as h, type EmmettCliCommand as i, isPluginConfig as j, isErrorConstructor as k, ConcurrencyInMemoryDatabaseError as l };
|