@contember/client 2.0.0-alpha.2 → 2.0.0-alpha.20
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/api-extractor.json +3 -0
- package/dist/development/index.cjs +11 -38
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +3 -33
- package/dist/development/index.js.map +1 -1
- package/dist/development/{content/upload → src}/GenerateUploadUrlMutationBuilder.cjs +9 -14
- package/dist/development/src/GenerateUploadUrlMutationBuilder.cjs.map +1 -0
- package/dist/development/{content/upload → src}/GenerateUploadUrlMutationBuilder.js +8 -13
- package/dist/development/src/GenerateUploadUrlMutationBuilder.js.map +1 -0
- package/dist/production/index.cjs +11 -38
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +3 -33
- package/dist/production/index.js.map +1 -1
- package/dist/production/{content/upload → src}/GenerateUploadUrlMutationBuilder.cjs +9 -14
- package/dist/production/src/GenerateUploadUrlMutationBuilder.cjs.map +1 -0
- package/dist/production/{content/upload → src}/GenerateUploadUrlMutationBuilder.js +8 -13
- package/dist/production/src/GenerateUploadUrlMutationBuilder.js.map +1 -0
- package/dist/types/{content/upload/GenerateUploadUrlMutationBuilder.d.ts → GenerateUploadUrlMutationBuilder.d.ts} +1 -2
- package/dist/types/GenerateUploadUrlMutationBuilder.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -17
- package/src/{content/upload/GenerateUploadUrlMutationBuilder.ts → GenerateUploadUrlMutationBuilder.ts} +3 -7
- package/src/index.ts +2 -19
- package/src/tsconfig.json +7 -1
- package/tests/cases/unit/generateUploadUrlMutationBuilder.spec.ts +79 -0
- package/tests/tsconfig.json +10 -0
- package/tsconfig.json +8 -0
- package/tsdoc.json +6 -0
- package/vitest.config.ts +3 -0
- package/dist/development/content/formatContentApiRelativeUrl.cjs +0 -5
- package/dist/development/content/formatContentApiRelativeUrl.cjs.map +0 -1
- package/dist/development/content/formatContentApiRelativeUrl.js +0 -5
- package/dist/development/content/formatContentApiRelativeUrl.js.map +0 -1
- package/dist/development/content/params/whereToFilter.cjs +0 -17
- package/dist/development/content/params/whereToFilter.cjs.map +0 -1
- package/dist/development/content/params/whereToFilter.js +0 -17
- package/dist/development/content/params/whereToFilter.js.map +0 -1
- package/dist/development/content/replaceGraphQlLiteral.cjs +0 -15
- package/dist/development/content/replaceGraphQlLiteral.cjs.map +0 -1
- package/dist/development/content/replaceGraphQlLiteral.js +0 -15
- package/dist/development/content/replaceGraphQlLiteral.js.map +0 -1
- package/dist/development/content/upload/FileUploadError.cjs +0 -10
- package/dist/development/content/upload/FileUploadError.cjs.map +0 -1
- package/dist/development/content/upload/FileUploadError.js +0 -10
- package/dist/development/content/upload/FileUploadError.js.map +0 -1
- package/dist/development/content/upload/GenerateUploadUrlMutationBuilder.cjs.map +0 -1
- package/dist/development/content/upload/GenerateUploadUrlMutationBuilder.js.map +0 -1
- package/dist/development/content/upload/S3FileUploader.cjs +0 -107
- package/dist/development/content/upload/S3FileUploader.cjs.map +0 -1
- package/dist/development/content/upload/S3FileUploader.js +0 -107
- package/dist/development/content/upload/S3FileUploader.js.map +0 -1
- package/dist/development/graphQlBuilder/GraphQlLiteral.cjs +0 -15
- package/dist/development/graphQlBuilder/GraphQlLiteral.cjs.map +0 -1
- package/dist/development/graphQlBuilder/GraphQlLiteral.js +0 -15
- package/dist/development/graphQlBuilder/GraphQlLiteral.js.map +0 -1
- package/dist/development/graphQlClient/GraphQlClient.cjs +0 -26
- package/dist/development/graphQlClient/GraphQlClient.cjs.map +0 -1
- package/dist/development/graphQlClient/GraphQlClient.js +0 -26
- package/dist/development/graphQlClient/GraphQlClient.js.map +0 -1
- package/dist/development/system/formatSystemApiRelativeUrl.cjs +0 -5
- package/dist/development/system/formatSystemApiRelativeUrl.cjs.map +0 -1
- package/dist/development/system/formatSystemApiRelativeUrl.js +0 -5
- package/dist/development/system/formatSystemApiRelativeUrl.js.map +0 -1
- package/dist/development/tenant/loginMutation.cjs +0 -34
- package/dist/development/tenant/loginMutation.cjs.map +0 -1
- package/dist/development/tenant/loginMutation.js +0 -34
- package/dist/development/tenant/loginMutation.js.map +0 -1
- package/dist/development/tenant/tenantApiRelativeUrl.cjs +0 -5
- package/dist/development/tenant/tenantApiRelativeUrl.cjs.map +0 -1
- package/dist/development/tenant/tenantApiRelativeUrl.js +0 -5
- package/dist/development/tenant/tenantApiRelativeUrl.js.map +0 -1
- package/dist/development/tenant/tenantErrorMessages.cjs +0 -18
- package/dist/development/tenant/tenantErrorMessages.cjs.map +0 -1
- package/dist/development/tenant/tenantErrorMessages.js +0 -18
- package/dist/development/tenant/tenantErrorMessages.js.map +0 -1
- package/dist/development/utils/readFileAsArrayBuffer.cjs +0 -15
- package/dist/development/utils/readFileAsArrayBuffer.cjs.map +0 -1
- package/dist/development/utils/readFileAsArrayBuffer.js +0 -15
- package/dist/development/utils/readFileAsArrayBuffer.js.map +0 -1
- package/dist/production/content/formatContentApiRelativeUrl.cjs +0 -5
- package/dist/production/content/formatContentApiRelativeUrl.cjs.map +0 -1
- package/dist/production/content/formatContentApiRelativeUrl.js +0 -5
- package/dist/production/content/formatContentApiRelativeUrl.js.map +0 -1
- package/dist/production/content/params/whereToFilter.cjs +0 -17
- package/dist/production/content/params/whereToFilter.cjs.map +0 -1
- package/dist/production/content/params/whereToFilter.js +0 -17
- package/dist/production/content/params/whereToFilter.js.map +0 -1
- package/dist/production/content/replaceGraphQlLiteral.cjs +0 -15
- package/dist/production/content/replaceGraphQlLiteral.cjs.map +0 -1
- package/dist/production/content/replaceGraphQlLiteral.js +0 -15
- package/dist/production/content/replaceGraphQlLiteral.js.map +0 -1
- package/dist/production/content/upload/FileUploadError.cjs +0 -10
- package/dist/production/content/upload/FileUploadError.cjs.map +0 -1
- package/dist/production/content/upload/FileUploadError.js +0 -10
- package/dist/production/content/upload/FileUploadError.js.map +0 -1
- package/dist/production/content/upload/GenerateUploadUrlMutationBuilder.cjs.map +0 -1
- package/dist/production/content/upload/GenerateUploadUrlMutationBuilder.js.map +0 -1
- package/dist/production/content/upload/S3FileUploader.cjs +0 -107
- package/dist/production/content/upload/S3FileUploader.cjs.map +0 -1
- package/dist/production/content/upload/S3FileUploader.js +0 -107
- package/dist/production/content/upload/S3FileUploader.js.map +0 -1
- package/dist/production/graphQlBuilder/GraphQlLiteral.cjs +0 -12
- package/dist/production/graphQlBuilder/GraphQlLiteral.cjs.map +0 -1
- package/dist/production/graphQlBuilder/GraphQlLiteral.js +0 -12
- package/dist/production/graphQlBuilder/GraphQlLiteral.js.map +0 -1
- package/dist/production/graphQlClient/GraphQlClient.cjs +0 -26
- package/dist/production/graphQlClient/GraphQlClient.cjs.map +0 -1
- package/dist/production/graphQlClient/GraphQlClient.js +0 -26
- package/dist/production/graphQlClient/GraphQlClient.js.map +0 -1
- package/dist/production/system/formatSystemApiRelativeUrl.cjs +0 -5
- package/dist/production/system/formatSystemApiRelativeUrl.cjs.map +0 -1
- package/dist/production/system/formatSystemApiRelativeUrl.js +0 -5
- package/dist/production/system/formatSystemApiRelativeUrl.js.map +0 -1
- package/dist/production/tenant/loginMutation.cjs +0 -34
- package/dist/production/tenant/loginMutation.cjs.map +0 -1
- package/dist/production/tenant/loginMutation.js +0 -34
- package/dist/production/tenant/loginMutation.js.map +0 -1
- package/dist/production/tenant/tenantApiRelativeUrl.cjs +0 -5
- package/dist/production/tenant/tenantApiRelativeUrl.cjs.map +0 -1
- package/dist/production/tenant/tenantApiRelativeUrl.js +0 -5
- package/dist/production/tenant/tenantApiRelativeUrl.js.map +0 -1
- package/dist/production/tenant/tenantErrorMessages.cjs +0 -18
- package/dist/production/tenant/tenantErrorMessages.cjs.map +0 -1
- package/dist/production/tenant/tenantErrorMessages.js +0 -18
- package/dist/production/tenant/tenantErrorMessages.js.map +0 -1
- package/dist/production/utils/readFileAsArrayBuffer.cjs +0 -15
- package/dist/production/utils/readFileAsArrayBuffer.cjs.map +0 -1
- package/dist/production/utils/readFileAsArrayBuffer.js +0 -15
- package/dist/production/utils/readFileAsArrayBuffer.js.map +0 -1
- package/dist/types/content/formatContentApiRelativeUrl.d.ts +0 -2
- package/dist/types/content/formatContentApiRelativeUrl.d.ts.map +0 -1
- package/dist/types/content/index.d.ts +0 -5
- package/dist/types/content/index.d.ts.map +0 -1
- package/dist/types/content/params/index.d.ts +0 -2
- package/dist/types/content/params/index.d.ts.map +0 -1
- package/dist/types/content/params/whereToFilter.d.ts +0 -4
- package/dist/types/content/params/whereToFilter.d.ts.map +0 -1
- package/dist/types/content/replaceGraphQlLiteral.d.ts +0 -6
- package/dist/types/content/replaceGraphQlLiteral.d.ts.map +0 -1
- package/dist/types/content/upload/FileUploadError.d.ts +0 -9
- package/dist/types/content/upload/FileUploadError.d.ts.map +0 -1
- package/dist/types/content/upload/FileUploadProgress.d.ts +0 -4
- package/dist/types/content/upload/FileUploadProgress.d.ts.map +0 -1
- package/dist/types/content/upload/FileUploader.d.ts +0 -15
- package/dist/types/content/upload/FileUploader.d.ts.map +0 -1
- package/dist/types/content/upload/GenerateUploadUrlMutationBuilder.d.ts.map +0 -1
- package/dist/types/content/upload/S3FileUploader.d.ts +0 -33
- package/dist/types/content/upload/S3FileUploader.d.ts.map +0 -1
- package/dist/types/content/upload/SwitchFileUploader.d.ts +0 -13
- package/dist/types/content/upload/SwitchFileUploader.d.ts.map +0 -1
- package/dist/types/content/upload/UploadedFileMetadata.d.ts +0 -4
- package/dist/types/content/upload/UploadedFileMetadata.d.ts.map +0 -1
- package/dist/types/content/upload/index.d.ts +0 -8
- package/dist/types/content/upload/index.d.ts.map +0 -1
- package/dist/types/crudQueryBuilder/index.d.ts +0 -2
- package/dist/types/crudQueryBuilder/index.d.ts.map +0 -1
- package/dist/types/crudQueryBuilder/types.d.ts +0 -4
- package/dist/types/crudQueryBuilder/types.d.ts.map +0 -1
- package/dist/types/graphQlBuilder/GraphQlLiteral.d.ts +0 -9
- package/dist/types/graphQlBuilder/GraphQlLiteral.d.ts.map +0 -1
- package/dist/types/graphQlBuilder/QueryBuilder.d.ts +0 -11
- package/dist/types/graphQlBuilder/QueryBuilder.d.ts.map +0 -1
- package/dist/types/graphQlBuilder/index.d.ts +0 -3
- package/dist/types/graphQlBuilder/index.d.ts.map +0 -1
- package/dist/types/graphQlClient/GraphQlClient.d.ts +0 -17
- package/dist/types/graphQlClient/GraphQlClient.d.ts.map +0 -1
- package/dist/types/graphQlClient/index.d.ts +0 -4
- package/dist/types/graphQlClient/index.d.ts.map +0 -1
- package/dist/types/system/events/RelationFilter.d.ts +0 -5
- package/dist/types/system/events/RelationFilter.d.ts.map +0 -1
- package/dist/types/system/events/SystemEvent.d.ts +0 -10
- package/dist/types/system/events/SystemEvent.d.ts.map +0 -1
- package/dist/types/system/events/TreeFilter.d.ts +0 -7
- package/dist/types/system/events/TreeFilter.d.ts.map +0 -1
- package/dist/types/system/events/index.d.ts +0 -4
- package/dist/types/system/events/index.d.ts.map +0 -1
- package/dist/types/system/formatSystemApiRelativeUrl.d.ts +0 -2
- package/dist/types/system/formatSystemApiRelativeUrl.d.ts.map +0 -1
- package/dist/types/system/index.d.ts +0 -3
- package/dist/types/system/index.d.ts.map +0 -1
- package/dist/types/tenant/index.d.ts +0 -4
- package/dist/types/tenant/index.d.ts.map +0 -1
- package/dist/types/tenant/loginMutation.d.ts +0 -32
- package/dist/types/tenant/loginMutation.d.ts.map +0 -1
- package/dist/types/tenant/tenantApiRelativeUrl.d.ts +0 -2
- package/dist/types/tenant/tenantApiRelativeUrl.d.ts.map +0 -1
- package/dist/types/tenant/tenantErrorMessages.d.ts +0 -5
- package/dist/types/tenant/tenantErrorMessages.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -3
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/isEmptyObject.d.ts +0 -2
- package/dist/types/utils/isEmptyObject.d.ts.map +0 -1
- package/dist/types/utils/readFileAsArrayBuffer.d.ts +0 -2
- package/dist/types/utils/readFileAsArrayBuffer.d.ts.map +0 -1
- package/src/content/formatContentApiRelativeUrl.ts +0 -2
- package/src/content/index.ts +0 -4
- package/src/content/params/index.ts +0 -1
- package/src/content/params/whereToFilter.ts +0 -19
- package/src/content/replaceGraphQlLiteral.ts +0 -22
- package/src/content/upload/FileUploadError.ts +0 -10
- package/src/content/upload/FileUploadProgress.ts +0 -3
- package/src/content/upload/FileUploader.ts +0 -19
- package/src/content/upload/S3FileUploader.ts +0 -150
- package/src/content/upload/SwitchFileUploader.ts +0 -40
- package/src/content/upload/UploadedFileMetadata.ts +0 -3
- package/src/content/upload/index.ts +0 -7
- package/src/crudQueryBuilder/index.ts +0 -1
- package/src/crudQueryBuilder/types.ts +0 -8
- package/src/graphQlBuilder/GraphQlLiteral.ts +0 -14
- package/src/graphQlBuilder/QueryBuilder.ts +0 -13
- package/src/graphQlBuilder/index.ts +0 -2
- package/src/graphQlClient/GraphQlClient.ts +0 -39
- package/src/graphQlClient/index.ts +0 -8
- package/src/system/events/RelationFilter.ts +0 -4
- package/src/system/events/SystemEvent.ts +0 -9
- package/src/system/events/TreeFilter.ts +0 -7
- package/src/system/events/index.ts +0 -3
- package/src/system/formatSystemApiRelativeUrl.ts +0 -1
- package/src/system/index.ts +0 -2
- package/src/tenant/index.ts +0 -3
- package/src/tenant/loginMutation.ts +0 -61
- package/src/tenant/tenantApiRelativeUrl.ts +0 -1
- package/src/tenant/tenantErrorMessages.ts +0 -14
- package/src/utils/index.ts +0 -2
- package/src/utils/isEmptyObject.ts +0 -9
- package/src/utils/readFileAsArrayBuffer.ts +0 -12
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whereToFilter.js","sources":["../../../../src/content/params/whereToFilter.ts"],"sourcesContent":["import type { Input, Writable } from '@contember/schema'\nimport { GraphQlLiteral } from '../../graphQlBuilder'\n\nexport const whereToFilter = (\n\tby: Input.UniqueWhere<GraphQlLiteral>,\n): Input.Where<Input.Condition<Input.ColumnValue<GraphQlLiteral>>> => {\n\tconst where: Writable<Input.Where<Input.Condition<Input.ColumnValue<GraphQlLiteral>>>> = {}\n\tfor (const key in by) {\n\t\tconst value = by[key]\n\n\t\tif (value instanceof GraphQlLiteral || typeof value === 'string' || typeof value === 'number') {\n\t\t\twhere[key] = { eq: value }\n\t\t} else {\n\t\t\twhere[key] = whereToFilter(value)\n\t\t}\n\t}\n\n\treturn where\n}\n"],"names":[],"mappings":";AAGa,MAAA,gBAAgB,CAC5B,OACqE;AACrE,QAAM,QAAmF,CAAA;AACzF,aAAW,OAAO,IAAI;AACf,UAAA,QAAQ,GAAG,GAAG;AAEpB,QAAI,iBAAiB,kBAAkB,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AAC9F,YAAM,GAAG,IAAI,EAAE,IAAI,MAAM;AAAA,IAAA,OACnB;AACA,YAAA,GAAG,IAAI,cAAc,KAAK;AAAA,IACjC;AAAA,EACD;AAEO,SAAA;AACR;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const GraphQlLiteral = require("../graphQlBuilder/GraphQlLiteral.cjs");
|
|
4
|
-
const replaceGraphQlLiteral = (input) => {
|
|
5
|
-
if (input instanceof GraphQlLiteral.GraphQlLiteral) {
|
|
6
|
-
return input.value;
|
|
7
|
-
} else if (Array.isArray(input)) {
|
|
8
|
-
return input.map(replaceGraphQlLiteral);
|
|
9
|
-
} else if (typeof input === "object" && input !== null) {
|
|
10
|
-
return Object.fromEntries(Object.entries(input).map(([key, value]) => value !== void 0 ? [key, replaceGraphQlLiteral(value)] : void 0).filter(Boolean));
|
|
11
|
-
}
|
|
12
|
-
return input;
|
|
13
|
-
};
|
|
14
|
-
exports.replaceGraphQlLiteral = replaceGraphQlLiteral;
|
|
15
|
-
//# sourceMappingURL=replaceGraphQlLiteral.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replaceGraphQlLiteral.cjs","sources":["../../../src/content/replaceGraphQlLiteral.ts"],"sourcesContent":["import { GraphQlLiteral } from '../graphQlBuilder'\n\nexport type ReplaceGraphQlLiteral<T> = T extends GraphQlLiteral<infer Value>\n\t? Value\n\t: T extends string | number | boolean | null\n\t\t? T // Keep primitives as is\n\t\t: T extends {}\n\t\t\t? { [K in keyof T]: ReplaceGraphQlLiteral<T[K]> } // Recursively apply to objects\n\t\t\t: T extends any[]\n\t\t\t\t? ReplaceGraphQlLiteral<T[number]>[] // Recursively apply to array elements\n\t\t\t\t: T;\n\nexport const replaceGraphQlLiteral = <T>(input: T): ReplaceGraphQlLiteral<T> => {\n\tif (input instanceof GraphQlLiteral) {\n\t\treturn input.value as any\n\t} else if (Array.isArray(input)) {\n\t\treturn input.map(replaceGraphQlLiteral) as any\n\t} else if (typeof input === 'object' && input !== null) {\n\t\treturn Object.fromEntries(Object.entries(input).map(([key, value]) => value !== undefined ? [key, replaceGraphQlLiteral(value)] : undefined).filter(Boolean) as any) as any\n\t}\n\treturn input as any\n}\n"],"names":["GraphQlLiteral"],"mappings":";;;AAYa,MAAA,wBAAwB,CAAI,UAAuC;AAC/E,MAAI,iBAAiBA,eAAAA,gBAAgB;AACpC,WAAO,MAAM;AAAA,EACH,WAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAA,MAAM,IAAI,qBAAqB;AAAA,EAC5B,WAAA,OAAO,UAAU,YAAY,UAAU,MAAM;AAChD,WAAA,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,UAAU,SAAY,CAAC,KAAK,sBAAsB,KAAK,CAAC,IAAI,MAAS,EAAE,OAAO,OAAO,CAAQ;AAAA,EACpK;AACO,SAAA;AACR;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { GraphQlLiteral } from "../graphQlBuilder/GraphQlLiteral.js";
|
|
2
|
-
const replaceGraphQlLiteral = (input) => {
|
|
3
|
-
if (input instanceof GraphQlLiteral) {
|
|
4
|
-
return input.value;
|
|
5
|
-
} else if (Array.isArray(input)) {
|
|
6
|
-
return input.map(replaceGraphQlLiteral);
|
|
7
|
-
} else if (typeof input === "object" && input !== null) {
|
|
8
|
-
return Object.fromEntries(Object.entries(input).map(([key, value]) => value !== void 0 ? [key, replaceGraphQlLiteral(value)] : void 0).filter(Boolean));
|
|
9
|
-
}
|
|
10
|
-
return input;
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
replaceGraphQlLiteral
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=replaceGraphQlLiteral.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replaceGraphQlLiteral.js","sources":["../../../src/content/replaceGraphQlLiteral.ts"],"sourcesContent":["import { GraphQlLiteral } from '../graphQlBuilder'\n\nexport type ReplaceGraphQlLiteral<T> = T extends GraphQlLiteral<infer Value>\n\t? Value\n\t: T extends string | number | boolean | null\n\t\t? T // Keep primitives as is\n\t\t: T extends {}\n\t\t\t? { [K in keyof T]: ReplaceGraphQlLiteral<T[K]> } // Recursively apply to objects\n\t\t\t: T extends any[]\n\t\t\t\t? ReplaceGraphQlLiteral<T[number]>[] // Recursively apply to array elements\n\t\t\t\t: T;\n\nexport const replaceGraphQlLiteral = <T>(input: T): ReplaceGraphQlLiteral<T> => {\n\tif (input instanceof GraphQlLiteral) {\n\t\treturn input.value as any\n\t} else if (Array.isArray(input)) {\n\t\treturn input.map(replaceGraphQlLiteral) as any\n\t} else if (typeof input === 'object' && input !== null) {\n\t\treturn Object.fromEntries(Object.entries(input).map(([key, value]) => value !== undefined ? [key, replaceGraphQlLiteral(value)] : undefined).filter(Boolean) as any) as any\n\t}\n\treturn input as any\n}\n"],"names":[],"mappings":";AAYa,MAAA,wBAAwB,CAAI,UAAuC;AAC/E,MAAI,iBAAiB,gBAAgB;AACpC,WAAO,MAAM;AAAA,EACH,WAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAA,MAAM,IAAI,qBAAqB;AAAA,EAC5B,WAAA,OAAO,UAAU,YAAY,UAAU,MAAM;AAChD,WAAA,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,UAAU,SAAY,CAAC,KAAK,sBAAsB,KAAK,CAAC,IAAI,MAAS,EAAE,OAAO,OAAO,CAAQ;AAAA,EACpK;AACO,SAAA;AACR;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class FileUploadError extends Error {
|
|
4
|
-
constructor(options = {}) {
|
|
5
|
-
super(options.developerMessage);
|
|
6
|
-
this.options = options;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.FileUploadError = FileUploadError;
|
|
10
|
-
//# sourceMappingURL=FileUploadError.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadError.cjs","sources":["../../../../src/content/upload/FileUploadError.ts"],"sourcesContent":["export interface FileUploadErrorOptions {\n\tdeveloperMessage?: string\n\tendUserMessage?: string\n}\n\nexport class FileUploadError extends Error {\n\tpublic constructor(public readonly options: FileUploadErrorOptions = {}) {\n\t\tsuper(options.developerMessage)\n\t}\n}\n"],"names":[],"mappings":";;AAKO,MAAM,wBAAwB,MAAM;AAAA,EACnC,YAA4B,UAAkC,IAAI;AACxE,UAAM,QAAQ,gBAAgB;AADI,SAAA,UAAA;AAAA,EAEnC;AACD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadError.js","sources":["../../../../src/content/upload/FileUploadError.ts"],"sourcesContent":["export interface FileUploadErrorOptions {\n\tdeveloperMessage?: string\n\tendUserMessage?: string\n}\n\nexport class FileUploadError extends Error {\n\tpublic constructor(public readonly options: FileUploadErrorOptions = {}) {\n\t\tsuper(options.developerMessage)\n\t}\n}\n"],"names":[],"mappings":"AAKO,MAAM,wBAAwB,MAAM;AAAA,EACnC,YAA4B,UAAkC,IAAI;AACxE,UAAM,QAAQ,gBAAgB;AADI,SAAA,UAAA;AAAA,EAEnC;AACD;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateUploadUrlMutationBuilder.cjs","sources":["../../../../src/content/upload/GenerateUploadUrlMutationBuilder.ts"],"sourcesContent":["import { GraphQlLiteral } from '../../graphQlBuilder'\nimport { GraphQlField, GraphQlPrintResult, GraphQlQueryPrinter, GraphQlSelectionSetItem } from '@contember/graphql-builder'\nimport { GraphQlBuilder } from '../../index'\nimport { replaceGraphQlLiteral } from '../replaceGraphQlLiteral'\n\nclass GenerateUploadUrlMutationBuilder {\n\tprivate static generateUploadUrlFields = [\n\t\tnew GraphQlField(null, 'url'),\n\t\tnew GraphQlField(null, 'publicUrl'),\n\t\tnew GraphQlField(null, 'method'),\n\t\tnew GraphQlField(null, 'headers', {}, [\n\t\t\tnew GraphQlField(null, 'key'),\n\t\t\tnew GraphQlField(null, 'value'),\n\t\t]),\n\t]\n\t/**\n\t * @internal\n\t */\n\tpublic static buildQuery(parameters: GenerateUploadUrlMutationBuilder.MutationParameters): GraphQlPrintResult {\n\t\tconst selectionItems: GraphQlSelectionSetItem[] = []\n\t\tfor (const alias in parameters) {\n\t\t\tconst fileParameters = parameters[alias]\n\t\t\tif (fileParameters.suffix || fileParameters.fileName || fileParameters.extension) {\n\t\t\t\tconst value = replaceGraphQlLiteral(fileParameters)\n\t\t\t\tselectionItems.push(new GraphQlField(alias, 'generateUploadUrl', {\n\t\t\t\t\tinput: {\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\tgraphQlType: 'S3GenerateSignedUploadInput',\n\t\t\t\t\t},\n\t\t\t\t}, GenerateUploadUrlMutationBuilder.generateUploadUrlFields))\n\t\t\t} else {\n\t\t\t\tselectionItems.push(new GraphQlField(alias, 'generateUploadUrl', {\n\t\t\t\t\tcontentType: {\n\t\t\t\t\t\tgraphQlType: 'String',\n\t\t\t\t\t\tvalue: fileParameters.contentType,\n\t\t\t\t\t},\n\t\t\t\t\texpiration: {\n\t\t\t\t\t\tgraphQlType: 'Int',\n\t\t\t\t\t\tvalue: fileParameters.expiration,\n\t\t\t\t\t},\n\t\t\t\t\tprefix: {\n\t\t\t\t\t\tgraphQlType: 'String',\n\t\t\t\t\t\tvalue: fileParameters.prefix,\n\t\t\t\t\t},\n\t\t\t\t\tacl: {\n\t\t\t\t\t\tgraphQlType: 'S3Acl',\n\t\t\t\t\t\tvalue: fileParameters.acl instanceof GraphQlBuilder.GraphqlLiteral ? fileParameters.acl?.value : fileParameters.acl,\n\t\t\t\t\t},\n\t\t\t\t}, GenerateUploadUrlMutationBuilder.generateUploadUrlFields))\n\t\t\t}\n\t\t}\n\n\t\tconst printer = new GraphQlQueryPrinter()\n\t\treturn printer.printDocument('mutation', selectionItems, {})\n\t}\n}\n\nnamespace GenerateUploadUrlMutationBuilder {\n\texport type Acl =\n\t\t| 'PUBLIC_READ'\n\t\t| 'PRIVATE'\n\t\t| 'NONE'\n\t\t| GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>\n\n\texport type FileParameters = {\n\t\tcontentType: string\n\t\texpiration?: number\n\t\tsize?: number\n\t\tprefix?: string\n\t\textension?: string\n\t\tsuffix?: string\n\t\tfileName?: string\n\t\tacl?: Acl\n\t}\n\n\texport interface MutationParameters {\n\t\t[alias: string]: FileParameters\n\t}\n\n\texport interface ResponseBody {\n\t\turl: string\n\t\tpublicUrl: string\n\t\tmethod: string\n\t\theaders: Array<{\n\t\t\tkey: string\n\t\t\tvalue: string\n\t\t}>\n\t}\n\n\texport interface MutationResponse {\n\t\t[alias: string]: ResponseBody\n\t}\n}\n\nexport { GenerateUploadUrlMutationBuilder }\n"],"names":["replaceGraphQlLiteral","GraphQlField","GraphQlBuilder","GraphQlQueryPrinter"],"mappings":";;;;;;;;;;;AAKA,MAAM,oCAAN,MAAM,kCAAiC;AAAA;AAAA;AAAA;AAAA,EAatC,OAAc,WAAW,YAAqF;AAC7G,UAAM,iBAA4C,CAAA;AAClD,eAAW,SAAS,YAAY;AACzB,YAAA,iBAAiB,WAAW,KAAK;AACvC,UAAI,eAAe,UAAU,eAAe,YAAY,eAAe,WAAW;AAC3E,cAAA,QAAQA,4CAAsB,cAAc;AAClD,uBAAe,KAAK,IAAIC,4BAAa,OAAO,qBAAqB;AAAA,UAChE,OAAO;AAAA,YACN;AAAA,YACA,aAAa;AAAA,UACd;AAAA,QAAA,GACE,kCAAiC,uBAAuB,CAAC;AAAA,MAAA,OACtD;AACN,uBAAe,KAAK,IAAIA,4BAAa,OAAO,qBAAqB;AAAA,UAChE,aAAa;AAAA,YACZ,aAAa;AAAA,YACb,OAAO,eAAe;AAAA,UACvB;AAAA,UACA,YAAY;AAAA,YACX,aAAa;AAAA,YACb,OAAO,eAAe;AAAA,UACvB;AAAA,UACA,QAAQ;AAAA,YACP,aAAa;AAAA,YACb,OAAO,eAAe;AAAA,UACvB;AAAA,UACA,KAAK;AAAA,YACJ,aAAa;AAAA,YACb,OAAO,eAAe,eAAeC,qBAAe,iBAAiB,eAAe,KAAK,QAAQ,eAAe;AAAA,UACjH;AAAA,QAAA,GACE,kCAAiC,uBAAuB,CAAC;AAAA,MAC7D;AAAA,IACD;AAEM,UAAA,UAAU,IAAIC,eAAAA;AACpB,WAAO,QAAQ,cAAc,YAAY,gBAAgB,CAAE,CAAA;AAAA,EAC5D;AACD;AAjDC,cADK,mCACU,2BAA0B;AAAA,EACxC,IAAIF,eAAa,aAAA,MAAM,KAAK;AAAA,EAC5B,IAAIA,eAAa,aAAA,MAAM,WAAW;AAAA,EAClC,IAAIA,eAAa,aAAA,MAAM,QAAQ;AAAA,EAC/B,IAAIA,4BAAa,MAAM,WAAW,IAAI;AAAA,IACrC,IAAIA,eAAa,aAAA,MAAM,KAAK;AAAA,IAC5B,IAAIA,eAAa,aAAA,MAAM,OAAO;AAAA,EAAA,CAC9B;AAAA;AARH,IAAM,mCAAN;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateUploadUrlMutationBuilder.js","sources":["../../../../src/content/upload/GenerateUploadUrlMutationBuilder.ts"],"sourcesContent":["import { GraphQlLiteral } from '../../graphQlBuilder'\nimport { GraphQlField, GraphQlPrintResult, GraphQlQueryPrinter, GraphQlSelectionSetItem } from '@contember/graphql-builder'\nimport { GraphQlBuilder } from '../../index'\nimport { replaceGraphQlLiteral } from '../replaceGraphQlLiteral'\n\nclass GenerateUploadUrlMutationBuilder {\n\tprivate static generateUploadUrlFields = [\n\t\tnew GraphQlField(null, 'url'),\n\t\tnew GraphQlField(null, 'publicUrl'),\n\t\tnew GraphQlField(null, 'method'),\n\t\tnew GraphQlField(null, 'headers', {}, [\n\t\t\tnew GraphQlField(null, 'key'),\n\t\t\tnew GraphQlField(null, 'value'),\n\t\t]),\n\t]\n\t/**\n\t * @internal\n\t */\n\tpublic static buildQuery(parameters: GenerateUploadUrlMutationBuilder.MutationParameters): GraphQlPrintResult {\n\t\tconst selectionItems: GraphQlSelectionSetItem[] = []\n\t\tfor (const alias in parameters) {\n\t\t\tconst fileParameters = parameters[alias]\n\t\t\tif (fileParameters.suffix || fileParameters.fileName || fileParameters.extension) {\n\t\t\t\tconst value = replaceGraphQlLiteral(fileParameters)\n\t\t\t\tselectionItems.push(new GraphQlField(alias, 'generateUploadUrl', {\n\t\t\t\t\tinput: {\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\tgraphQlType: 'S3GenerateSignedUploadInput',\n\t\t\t\t\t},\n\t\t\t\t}, GenerateUploadUrlMutationBuilder.generateUploadUrlFields))\n\t\t\t} else {\n\t\t\t\tselectionItems.push(new GraphQlField(alias, 'generateUploadUrl', {\n\t\t\t\t\tcontentType: {\n\t\t\t\t\t\tgraphQlType: 'String',\n\t\t\t\t\t\tvalue: fileParameters.contentType,\n\t\t\t\t\t},\n\t\t\t\t\texpiration: {\n\t\t\t\t\t\tgraphQlType: 'Int',\n\t\t\t\t\t\tvalue: fileParameters.expiration,\n\t\t\t\t\t},\n\t\t\t\t\tprefix: {\n\t\t\t\t\t\tgraphQlType: 'String',\n\t\t\t\t\t\tvalue: fileParameters.prefix,\n\t\t\t\t\t},\n\t\t\t\t\tacl: {\n\t\t\t\t\t\tgraphQlType: 'S3Acl',\n\t\t\t\t\t\tvalue: fileParameters.acl instanceof GraphQlBuilder.GraphqlLiteral ? fileParameters.acl?.value : fileParameters.acl,\n\t\t\t\t\t},\n\t\t\t\t}, GenerateUploadUrlMutationBuilder.generateUploadUrlFields))\n\t\t\t}\n\t\t}\n\n\t\tconst printer = new GraphQlQueryPrinter()\n\t\treturn printer.printDocument('mutation', selectionItems, {})\n\t}\n}\n\nnamespace GenerateUploadUrlMutationBuilder {\n\texport type Acl =\n\t\t| 'PUBLIC_READ'\n\t\t| 'PRIVATE'\n\t\t| 'NONE'\n\t\t| GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>\n\n\texport type FileParameters = {\n\t\tcontentType: string\n\t\texpiration?: number\n\t\tsize?: number\n\t\tprefix?: string\n\t\textension?: string\n\t\tsuffix?: string\n\t\tfileName?: string\n\t\tacl?: Acl\n\t}\n\n\texport interface MutationParameters {\n\t\t[alias: string]: FileParameters\n\t}\n\n\texport interface ResponseBody {\n\t\turl: string\n\t\tpublicUrl: string\n\t\tmethod: string\n\t\theaders: Array<{\n\t\t\tkey: string\n\t\t\tvalue: string\n\t\t}>\n\t}\n\n\texport interface MutationResponse {\n\t\t[alias: string]: ResponseBody\n\t}\n}\n\nexport { GenerateUploadUrlMutationBuilder }\n"],"names":[],"mappings":";;;;;;;;;AAKA,MAAM,oCAAN,MAAM,kCAAiC;AAAA;AAAA;AAAA;AAAA,EAatC,OAAc,WAAW,YAAqF;AAC7G,UAAM,iBAA4C,CAAA;AAClD,eAAW,SAAS,YAAY;AACzB,YAAA,iBAAiB,WAAW,KAAK;AACvC,UAAI,eAAe,UAAU,eAAe,YAAY,eAAe,WAAW;AAC3E,cAAA,QAAQ,sBAAsB,cAAc;AAClD,uBAAe,KAAK,IAAI,aAAa,OAAO,qBAAqB;AAAA,UAChE,OAAO;AAAA,YACN;AAAA,YACA,aAAa;AAAA,UACd;AAAA,QAAA,GACE,kCAAiC,uBAAuB,CAAC;AAAA,MAAA,OACtD;AACN,uBAAe,KAAK,IAAI,aAAa,OAAO,qBAAqB;AAAA,UAChE,aAAa;AAAA,YACZ,aAAa;AAAA,YACb,OAAO,eAAe;AAAA,UACvB;AAAA,UACA,YAAY;AAAA,YACX,aAAa;AAAA,YACb,OAAO,eAAe;AAAA,UACvB;AAAA,UACA,QAAQ;AAAA,YACP,aAAa;AAAA,YACb,OAAO,eAAe;AAAA,UACvB;AAAA,UACA,KAAK;AAAA,YACJ,aAAa;AAAA,YACb,OAAO,eAAe,eAAe,eAAe,iBAAiB,eAAe,KAAK,QAAQ,eAAe;AAAA,UACjH;AAAA,QAAA,GACE,kCAAiC,uBAAuB,CAAC;AAAA,MAC7D;AAAA,IACD;AAEM,UAAA,UAAU,IAAI;AACpB,WAAO,QAAQ,cAAc,YAAY,gBAAgB,CAAE,CAAA;AAAA,EAC5D;AACD;AAjDC,cADK,mCACU,2BAA0B;AAAA,EACxC,IAAI,aAAa,MAAM,KAAK;AAAA,EAC5B,IAAI,aAAa,MAAM,WAAW;AAAA,EAClC,IAAI,aAAa,MAAM,QAAQ;AAAA,EAC/B,IAAI,aAAa,MAAM,WAAW,IAAI;AAAA,IACrC,IAAI,aAAa,MAAM,KAAK;AAAA,IAC5B,IAAI,aAAa,MAAM,OAAO;AAAA,EAAA,CAC9B;AAAA;AARH,IAAM,mCAAN;"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => {
|
|
5
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
return value;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
9
|
-
const pLimit = require("p-limit");
|
|
10
|
-
const FileUploadError = require("./FileUploadError.cjs");
|
|
11
|
-
const GenerateUploadUrlMutationBuilder = require("./GenerateUploadUrlMutationBuilder.cjs");
|
|
12
|
-
const readFileAsArrayBuffer = require("../../utils/readFileAsArrayBuffer.cjs");
|
|
13
|
-
class S3FileUploader {
|
|
14
|
-
constructor(options = {}) {
|
|
15
|
-
__publicField(this, "uploadState");
|
|
16
|
-
__publicField(this, "generateNewAlias", /* @__PURE__ */ (() => {
|
|
17
|
-
let alias = 1;
|
|
18
|
-
return () => alias++;
|
|
19
|
-
})());
|
|
20
|
-
this.options = options;
|
|
21
|
-
this.uploadState = /* @__PURE__ */ new WeakMap();
|
|
22
|
-
}
|
|
23
|
-
static formatFullAlias(alias) {
|
|
24
|
-
return `file${alias}`;
|
|
25
|
-
}
|
|
26
|
-
async upload(files, options) {
|
|
27
|
-
const parameters = {};
|
|
28
|
-
for (const [file, metadata] of files) {
|
|
29
|
-
if (this.uploadState.has(file)) {
|
|
30
|
-
const uploadState = this.uploadState.get(file);
|
|
31
|
-
uploadState.request?.abort();
|
|
32
|
-
}
|
|
33
|
-
const alias = this.generateNewAlias();
|
|
34
|
-
this.uploadState.set(file, {
|
|
35
|
-
alias
|
|
36
|
-
});
|
|
37
|
-
const uploadOptions = this.options.getUploadOptions?.(file);
|
|
38
|
-
parameters[S3FileUploader.formatFullAlias(alias)] = {
|
|
39
|
-
contentType: uploadOptions?.fileType ?? file.type,
|
|
40
|
-
prefix: uploadOptions?.filePrefix,
|
|
41
|
-
suffix: uploadOptions?.fileSuffix,
|
|
42
|
-
size: uploadOptions?.fileSize,
|
|
43
|
-
extension: uploadOptions?.fileExtension,
|
|
44
|
-
fileName: uploadOptions?.fileName,
|
|
45
|
-
expiration: uploadOptions?.fileExpiration,
|
|
46
|
-
acl: uploadOptions?.fileAcl
|
|
47
|
-
};
|
|
48
|
-
metadata.abortSignal.addEventListener("abort", () => {
|
|
49
|
-
this.uploadState.get(file)?.request?.abort();
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const mutation = GenerateUploadUrlMutationBuilder.GenerateUploadUrlMutationBuilder.buildQuery(parameters);
|
|
53
|
-
try {
|
|
54
|
-
const responseData = await options.contentApiClient.execute(mutation.query, { variables: mutation.variables });
|
|
55
|
-
const limit = pLimit(this.options.concurrency ?? 5);
|
|
56
|
-
const promises = [];
|
|
57
|
-
for (const [file] of files) {
|
|
58
|
-
promises.push(limit(() => this.uploadSingleFile(file, responseData, options)));
|
|
59
|
-
}
|
|
60
|
-
await Promise.all(promises);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
if (error instanceof FileUploadError.FileUploadError) {
|
|
63
|
-
const fileUploadError = error;
|
|
64
|
-
options.onError(Array.from(files).map(([file]) => [file, fileUploadError]));
|
|
65
|
-
} else {
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
uploadSingleFile(file, responseData, { onProgress, onError, onSuccess }) {
|
|
71
|
-
return new Promise(async (resolve, reject) => {
|
|
72
|
-
const fileState = this.uploadState.get(file);
|
|
73
|
-
const datumBody = responseData[S3FileUploader.formatFullAlias(fileState.alias)];
|
|
74
|
-
const uploadRequestBody = await readFileAsArrayBuffer.readFileAsArrayBuffer(file);
|
|
75
|
-
const xhr = new XMLHttpRequest();
|
|
76
|
-
fileState.request = xhr;
|
|
77
|
-
xhr.open(datumBody.method, datumBody.url);
|
|
78
|
-
for (const header of datumBody.headers) {
|
|
79
|
-
xhr.setRequestHeader(header.key, header.value);
|
|
80
|
-
}
|
|
81
|
-
xhr.addEventListener("load", () => {
|
|
82
|
-
const successMetadata = {
|
|
83
|
-
fileUrl: datumBody.publicUrl
|
|
84
|
-
};
|
|
85
|
-
onSuccess([[file, successMetadata]]);
|
|
86
|
-
resolve();
|
|
87
|
-
});
|
|
88
|
-
xhr.addEventListener("error", (e) => {
|
|
89
|
-
onError([file]);
|
|
90
|
-
reject(e);
|
|
91
|
-
});
|
|
92
|
-
xhr.upload?.addEventListener("progress", (e) => {
|
|
93
|
-
onProgress([
|
|
94
|
-
[
|
|
95
|
-
file,
|
|
96
|
-
{
|
|
97
|
-
progress: e.loaded / e.total
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
]);
|
|
101
|
-
});
|
|
102
|
-
xhr.send(uploadRequestBody);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.S3FileUploader = S3FileUploader;
|
|
107
|
-
//# sourceMappingURL=S3FileUploader.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S3FileUploader.cjs","sources":["../../../../src/content/upload/S3FileUploader.ts"],"sourcesContent":["import pLimit from 'p-limit'\nimport { readFileAsArrayBuffer } from '../../utils'\nimport { FileUploadError } from './FileUploadError'\nimport type { FileUploader, FileUploaderInitializeOptions } from './FileUploader'\nimport { GenerateUploadUrlMutationBuilder } from './GenerateUploadUrlMutationBuilder'\nimport type { UploadedFileMetadata } from './UploadedFileMetadata'\n\ninterface S3UploadState {\n\trequest?: XMLHttpRequest\n\talias: number\n}\n\nclass S3FileUploader implements FileUploader<S3FileUploader.SuccessMetadata> {\n\tprivate readonly uploadState: WeakMap<File, S3UploadState>\n\n\tpublic constructor(public readonly options: S3FileUploader.Options = {}) {\n\t\tthis.uploadState = new WeakMap()\n\t}\n\n\tprivate generateNewAlias = (() => {\n\t\tlet alias = 1\n\t\treturn () => alias++\n\t})()\n\n\tprivate static formatFullAlias(alias: number) {\n\t\treturn `file${alias}`\n\t}\n\n\tpublic async upload(\n\t\tfiles: Map<File, UploadedFileMetadata>,\n\t\toptions: FileUploaderInitializeOptions,\n\t) {\n\t\tconst parameters: GenerateUploadUrlMutationBuilder.MutationParameters = {}\n\n\t\tfor (const [file, metadata] of files) {\n\t\t\tif (this.uploadState.has(file)) {\n\t\t\t\tconst uploadState = this.uploadState.get(file)!\n\t\t\t\tuploadState.request?.abort()\n\t\t\t}\n\n\t\t\tconst alias = this.generateNewAlias()\n\t\t\tthis.uploadState.set(file, {\n\t\t\t\talias,\n\t\t\t})\n\n\t\t\tconst uploadOptions = this.options.getUploadOptions?.(file)\n\n\t\t\tparameters[S3FileUploader.formatFullAlias(alias)] = {\n\t\t\t\tcontentType: uploadOptions?.fileType ?? file.type,\n\t\t\t\tprefix: uploadOptions?.filePrefix,\n\t\t\t\tsuffix: uploadOptions?.fileSuffix,\n\t\t\t\tsize: uploadOptions?.fileSize,\n\t\t\t\textension: uploadOptions?.fileExtension,\n\t\t\t\tfileName: uploadOptions?.fileName,\n\t\t\t\texpiration: uploadOptions?.fileExpiration,\n\t\t\t\tacl: uploadOptions?.fileAcl,\n\t\t\t}\n\n\t\t\tmetadata.abortSignal.addEventListener('abort', () => {\n\t\t\t\tthis.uploadState.get(file)?.request?.abort()\n\t\t\t})\n\t\t}\n\n\t\tconst mutation = GenerateUploadUrlMutationBuilder.buildQuery(parameters)\n\t\ttry {\n\t\t\tconst responseData = await options.contentApiClient.execute<GenerateUploadUrlMutationBuilder.MutationResponse>(mutation.query, { variables: mutation.variables })\n\t\t\tconst limit = pLimit(this.options.concurrency ?? 5)\n\t\t\tconst promises: Promise<void>[] = []\n\t\t\tfor (const [file] of files) {\n\t\t\t\tpromises.push(limit(() => this.uploadSingleFile(file, responseData, options)))\n\t\t\t}\n\t\t\tawait Promise.all(promises)\n\t\t} catch (error) {\n\t\t\tif (error instanceof FileUploadError) {\n\t\t\t\tconst fileUploadError = error\n\t\t\t\toptions.onError(Array.from(files).map(([file]) => [file, fileUploadError]))\n\n\t\t\t} else {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate uploadSingleFile(\n\t\tfile: File,\n\t\tresponseData: GenerateUploadUrlMutationBuilder.MutationResponse,\n\t\t{ onProgress, onError, onSuccess }: FileUploaderInitializeOptions,\n\t) {\n\t\treturn new Promise<void>(async (resolve, reject) => {\n\t\t\tconst fileState = this.uploadState.get(file)!\n\t\t\tconst datumBody = responseData[S3FileUploader.formatFullAlias(fileState.alias)]\n\t\t\tconst uploadRequestBody = await readFileAsArrayBuffer(file)\n\t\t\tconst xhr = new XMLHttpRequest()\n\n\t\t\tfileState.request = xhr\n\n\t\t\txhr.open(datumBody.method, datumBody.url)\n\n\t\t\tfor (const header of datumBody.headers) {\n\t\t\t\txhr.setRequestHeader(header.key, header.value)\n\t\t\t}\n\t\t\txhr.addEventListener('load', () => {\n\t\t\t\tconst successMetadata: S3FileUploader.SuccessMetadata = {\n\t\t\t\t\tfileUrl: datumBody.publicUrl,\n\t\t\t\t}\n\t\t\t\tonSuccess([[file, successMetadata]])\n\t\t\t\tresolve()\n\t\t\t})\n\t\t\txhr.addEventListener('error', e => {\n\t\t\t\tonError([file])\n\t\t\t\treject(e)\n\t\t\t})\n\t\t\txhr.upload?.addEventListener('progress', e => {\n\t\t\t\tonProgress([\n\t\t\t\t\t[\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tprogress: e.loaded / e.total,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t})\n\t\t\txhr.send(uploadRequestBody)\n\t\t})\n\t}\n}\n\nnamespace S3FileUploader {\n\texport interface SuccessMetadata {\n\t\tfileUrl: string\n\t}\n\n\texport interface Options {\n\t\tgetUploadOptions?: (file: File) => S3UploadOptions\n\t\tconcurrency?: number\n\t}\n\n\texport interface S3UploadOptions {\n\t\tfileType?: GenerateUploadUrlMutationBuilder.FileParameters['contentType']\n\t\tfileExpiration?: number\n\t\tfileSize?: number\n\t\tfilePrefix?: string\n\t\tfileSuffix?: string\n\t\tfileName?: string\n\t\tfileExtension?: string\n\t\tfileAcl?: GenerateUploadUrlMutationBuilder.Acl\n\t}\n}\n\nexport { S3FileUploader }\n"],"names":["GenerateUploadUrlMutationBuilder","FileUploadError","readFileAsArrayBuffer"],"mappings":"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"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import pLimit from "p-limit";
|
|
8
|
-
import { FileUploadError } from "./FileUploadError.js";
|
|
9
|
-
import { GenerateUploadUrlMutationBuilder } from "./GenerateUploadUrlMutationBuilder.js";
|
|
10
|
-
import { readFileAsArrayBuffer } from "../../utils/readFileAsArrayBuffer.js";
|
|
11
|
-
class S3FileUploader {
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
__publicField(this, "uploadState");
|
|
14
|
-
__publicField(this, "generateNewAlias", /* @__PURE__ */ (() => {
|
|
15
|
-
let alias = 1;
|
|
16
|
-
return () => alias++;
|
|
17
|
-
})());
|
|
18
|
-
this.options = options;
|
|
19
|
-
this.uploadState = /* @__PURE__ */ new WeakMap();
|
|
20
|
-
}
|
|
21
|
-
static formatFullAlias(alias) {
|
|
22
|
-
return `file${alias}`;
|
|
23
|
-
}
|
|
24
|
-
async upload(files, options) {
|
|
25
|
-
const parameters = {};
|
|
26
|
-
for (const [file, metadata] of files) {
|
|
27
|
-
if (this.uploadState.has(file)) {
|
|
28
|
-
const uploadState = this.uploadState.get(file);
|
|
29
|
-
uploadState.request?.abort();
|
|
30
|
-
}
|
|
31
|
-
const alias = this.generateNewAlias();
|
|
32
|
-
this.uploadState.set(file, {
|
|
33
|
-
alias
|
|
34
|
-
});
|
|
35
|
-
const uploadOptions = this.options.getUploadOptions?.(file);
|
|
36
|
-
parameters[S3FileUploader.formatFullAlias(alias)] = {
|
|
37
|
-
contentType: uploadOptions?.fileType ?? file.type,
|
|
38
|
-
prefix: uploadOptions?.filePrefix,
|
|
39
|
-
suffix: uploadOptions?.fileSuffix,
|
|
40
|
-
size: uploadOptions?.fileSize,
|
|
41
|
-
extension: uploadOptions?.fileExtension,
|
|
42
|
-
fileName: uploadOptions?.fileName,
|
|
43
|
-
expiration: uploadOptions?.fileExpiration,
|
|
44
|
-
acl: uploadOptions?.fileAcl
|
|
45
|
-
};
|
|
46
|
-
metadata.abortSignal.addEventListener("abort", () => {
|
|
47
|
-
this.uploadState.get(file)?.request?.abort();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const mutation = GenerateUploadUrlMutationBuilder.buildQuery(parameters);
|
|
51
|
-
try {
|
|
52
|
-
const responseData = await options.contentApiClient.execute(mutation.query, { variables: mutation.variables });
|
|
53
|
-
const limit = pLimit(this.options.concurrency ?? 5);
|
|
54
|
-
const promises = [];
|
|
55
|
-
for (const [file] of files) {
|
|
56
|
-
promises.push(limit(() => this.uploadSingleFile(file, responseData, options)));
|
|
57
|
-
}
|
|
58
|
-
await Promise.all(promises);
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (error instanceof FileUploadError) {
|
|
61
|
-
const fileUploadError = error;
|
|
62
|
-
options.onError(Array.from(files).map(([file]) => [file, fileUploadError]));
|
|
63
|
-
} else {
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
uploadSingleFile(file, responseData, { onProgress, onError, onSuccess }) {
|
|
69
|
-
return new Promise(async (resolve, reject) => {
|
|
70
|
-
const fileState = this.uploadState.get(file);
|
|
71
|
-
const datumBody = responseData[S3FileUploader.formatFullAlias(fileState.alias)];
|
|
72
|
-
const uploadRequestBody = await readFileAsArrayBuffer(file);
|
|
73
|
-
const xhr = new XMLHttpRequest();
|
|
74
|
-
fileState.request = xhr;
|
|
75
|
-
xhr.open(datumBody.method, datumBody.url);
|
|
76
|
-
for (const header of datumBody.headers) {
|
|
77
|
-
xhr.setRequestHeader(header.key, header.value);
|
|
78
|
-
}
|
|
79
|
-
xhr.addEventListener("load", () => {
|
|
80
|
-
const successMetadata = {
|
|
81
|
-
fileUrl: datumBody.publicUrl
|
|
82
|
-
};
|
|
83
|
-
onSuccess([[file, successMetadata]]);
|
|
84
|
-
resolve();
|
|
85
|
-
});
|
|
86
|
-
xhr.addEventListener("error", (e) => {
|
|
87
|
-
onError([file]);
|
|
88
|
-
reject(e);
|
|
89
|
-
});
|
|
90
|
-
xhr.upload?.addEventListener("progress", (e) => {
|
|
91
|
-
onProgress([
|
|
92
|
-
[
|
|
93
|
-
file,
|
|
94
|
-
{
|
|
95
|
-
progress: e.loaded / e.total
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
]);
|
|
99
|
-
});
|
|
100
|
-
xhr.send(uploadRequestBody);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
export {
|
|
105
|
-
S3FileUploader
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=S3FileUploader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S3FileUploader.js","sources":["../../../../src/content/upload/S3FileUploader.ts"],"sourcesContent":["import pLimit from 'p-limit'\nimport { readFileAsArrayBuffer } from '../../utils'\nimport { FileUploadError } from './FileUploadError'\nimport type { FileUploader, FileUploaderInitializeOptions } from './FileUploader'\nimport { GenerateUploadUrlMutationBuilder } from './GenerateUploadUrlMutationBuilder'\nimport type { UploadedFileMetadata } from './UploadedFileMetadata'\n\ninterface S3UploadState {\n\trequest?: XMLHttpRequest\n\talias: number\n}\n\nclass S3FileUploader implements FileUploader<S3FileUploader.SuccessMetadata> {\n\tprivate readonly uploadState: WeakMap<File, S3UploadState>\n\n\tpublic constructor(public readonly options: S3FileUploader.Options = {}) {\n\t\tthis.uploadState = new WeakMap()\n\t}\n\n\tprivate generateNewAlias = (() => {\n\t\tlet alias = 1\n\t\treturn () => alias++\n\t})()\n\n\tprivate static formatFullAlias(alias: number) {\n\t\treturn `file${alias}`\n\t}\n\n\tpublic async upload(\n\t\tfiles: Map<File, UploadedFileMetadata>,\n\t\toptions: FileUploaderInitializeOptions,\n\t) {\n\t\tconst parameters: GenerateUploadUrlMutationBuilder.MutationParameters = {}\n\n\t\tfor (const [file, metadata] of files) {\n\t\t\tif (this.uploadState.has(file)) {\n\t\t\t\tconst uploadState = this.uploadState.get(file)!\n\t\t\t\tuploadState.request?.abort()\n\t\t\t}\n\n\t\t\tconst alias = this.generateNewAlias()\n\t\t\tthis.uploadState.set(file, {\n\t\t\t\talias,\n\t\t\t})\n\n\t\t\tconst uploadOptions = this.options.getUploadOptions?.(file)\n\n\t\t\tparameters[S3FileUploader.formatFullAlias(alias)] = {\n\t\t\t\tcontentType: uploadOptions?.fileType ?? file.type,\n\t\t\t\tprefix: uploadOptions?.filePrefix,\n\t\t\t\tsuffix: uploadOptions?.fileSuffix,\n\t\t\t\tsize: uploadOptions?.fileSize,\n\t\t\t\textension: uploadOptions?.fileExtension,\n\t\t\t\tfileName: uploadOptions?.fileName,\n\t\t\t\texpiration: uploadOptions?.fileExpiration,\n\t\t\t\tacl: uploadOptions?.fileAcl,\n\t\t\t}\n\n\t\t\tmetadata.abortSignal.addEventListener('abort', () => {\n\t\t\t\tthis.uploadState.get(file)?.request?.abort()\n\t\t\t})\n\t\t}\n\n\t\tconst mutation = GenerateUploadUrlMutationBuilder.buildQuery(parameters)\n\t\ttry {\n\t\t\tconst responseData = await options.contentApiClient.execute<GenerateUploadUrlMutationBuilder.MutationResponse>(mutation.query, { variables: mutation.variables })\n\t\t\tconst limit = pLimit(this.options.concurrency ?? 5)\n\t\t\tconst promises: Promise<void>[] = []\n\t\t\tfor (const [file] of files) {\n\t\t\t\tpromises.push(limit(() => this.uploadSingleFile(file, responseData, options)))\n\t\t\t}\n\t\t\tawait Promise.all(promises)\n\t\t} catch (error) {\n\t\t\tif (error instanceof FileUploadError) {\n\t\t\t\tconst fileUploadError = error\n\t\t\t\toptions.onError(Array.from(files).map(([file]) => [file, fileUploadError]))\n\n\t\t\t} else {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate uploadSingleFile(\n\t\tfile: File,\n\t\tresponseData: GenerateUploadUrlMutationBuilder.MutationResponse,\n\t\t{ onProgress, onError, onSuccess }: FileUploaderInitializeOptions,\n\t) {\n\t\treturn new Promise<void>(async (resolve, reject) => {\n\t\t\tconst fileState = this.uploadState.get(file)!\n\t\t\tconst datumBody = responseData[S3FileUploader.formatFullAlias(fileState.alias)]\n\t\t\tconst uploadRequestBody = await readFileAsArrayBuffer(file)\n\t\t\tconst xhr = new XMLHttpRequest()\n\n\t\t\tfileState.request = xhr\n\n\t\t\txhr.open(datumBody.method, datumBody.url)\n\n\t\t\tfor (const header of datumBody.headers) {\n\t\t\t\txhr.setRequestHeader(header.key, header.value)\n\t\t\t}\n\t\t\txhr.addEventListener('load', () => {\n\t\t\t\tconst successMetadata: S3FileUploader.SuccessMetadata = {\n\t\t\t\t\tfileUrl: datumBody.publicUrl,\n\t\t\t\t}\n\t\t\t\tonSuccess([[file, successMetadata]])\n\t\t\t\tresolve()\n\t\t\t})\n\t\t\txhr.addEventListener('error', e => {\n\t\t\t\tonError([file])\n\t\t\t\treject(e)\n\t\t\t})\n\t\t\txhr.upload?.addEventListener('progress', e => {\n\t\t\t\tonProgress([\n\t\t\t\t\t[\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tprogress: e.loaded / e.total,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t])\n\t\t\t})\n\t\t\txhr.send(uploadRequestBody)\n\t\t})\n\t}\n}\n\nnamespace S3FileUploader {\n\texport interface SuccessMetadata {\n\t\tfileUrl: string\n\t}\n\n\texport interface Options {\n\t\tgetUploadOptions?: (file: File) => S3UploadOptions\n\t\tconcurrency?: number\n\t}\n\n\texport interface S3UploadOptions {\n\t\tfileType?: GenerateUploadUrlMutationBuilder.FileParameters['contentType']\n\t\tfileExpiration?: number\n\t\tfileSize?: number\n\t\tfilePrefix?: string\n\t\tfileSuffix?: string\n\t\tfileName?: string\n\t\tfileExtension?: string\n\t\tfileAcl?: GenerateUploadUrlMutationBuilder.Acl\n\t}\n}\n\nexport { S3FileUploader }\n"],"names":[],"mappings":"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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class GraphQlLiteral {
|
|
4
|
-
constructor(value) {
|
|
5
|
-
this.value = value;
|
|
6
|
-
}
|
|
7
|
-
toString() {
|
|
8
|
-
return `Literal(${this.value})`;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.GraphQlLiteral = GraphQlLiteral;
|
|
12
|
-
//# sourceMappingURL=GraphQlLiteral.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlLiteral.cjs","sources":["../../../src/graphQlBuilder/GraphQlLiteral.ts"],"sourcesContent":["/**\n * @deprecated Directly use the value instead.\n */\nexport class GraphQlLiteral<Value extends string = string> {\n\tconstructor(public readonly value: Value) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tconsole.warn('GraphQlLiteral is deprecated, use the value directly instead.')\n\t\t}\n\t}\n\n\tpublic toString() {\n\t\treturn `Literal(${this.value})`\n\t}\n}\n"],"names":[],"mappings":";;AAGO,MAAM,eAA8C;AAAA,EAC1D,YAA4B,OAAc;AAAd,SAAA,QAAA;AAAA,EAI5B;AAAA,EAEO,WAAW;AACV,WAAA,WAAW,KAAK,KAAK;AAAA,EAC7B;AACD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlLiteral.js","sources":["../../../src/graphQlBuilder/GraphQlLiteral.ts"],"sourcesContent":["/**\n * @deprecated Directly use the value instead.\n */\nexport class GraphQlLiteral<Value extends string = string> {\n\tconstructor(public readonly value: Value) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tconsole.warn('GraphQlLiteral is deprecated, use the value directly instead.')\n\t\t}\n\t}\n\n\tpublic toString() {\n\t\treturn `Literal(${this.value})`\n\t}\n}\n"],"names":[],"mappings":"AAGO,MAAM,eAA8C;AAAA,EAC1D,YAA4B,OAAc;AAAd,SAAA,QAAA;AAAA,EAI5B;AAAA,EAEO,WAAW;AACV,WAAA,WAAW,KAAK,KAAK;AAAA,EAC7B;AACD;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const graphqlClient = require("@contember/graphql-client");
|
|
4
|
-
class GraphQlClient extends graphqlClient.GraphQlClient {
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated use execute
|
|
7
|
-
*/
|
|
8
|
-
async sendRequest(query, options = {}) {
|
|
9
|
-
console.debug(query);
|
|
10
|
-
const response = await this.doExecute(query, {
|
|
11
|
-
...options,
|
|
12
|
-
apiToken: options.apiTokenOverride ?? options.apiToken
|
|
13
|
-
});
|
|
14
|
-
if (response.ok) {
|
|
15
|
-
return await response.json();
|
|
16
|
-
}
|
|
17
|
-
const failedRequest = {
|
|
18
|
-
status: response.status,
|
|
19
|
-
statusText: response.statusText,
|
|
20
|
-
responseText: await response.text()
|
|
21
|
-
};
|
|
22
|
-
return Promise.reject(failedRequest);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.GraphQlClient = GraphQlClient;
|
|
26
|
-
//# sourceMappingURL=GraphQlClient.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlClient.cjs","sources":["../../../src/graphQlClient/GraphQlClient.ts"],"sourcesContent":["import { GraphQlClient as BaseGraphQLClient, GraphQlClientRequestOptions as BaseGraphQlClientRequestOptions } from '@contember/graphql-client'\n\nexport interface GraphQlClientRequestOptions extends BaseGraphQlClientRequestOptions {\n\t/**\n\t * @deprecated use apiToken\n\t */\n\tapiTokenOverride?: string\n}\n\nexport type GraphQlClientFailedRequestMetadata = Pick<Response, 'status' | 'statusText'> & {\n\tresponseText: string\n}\n\nexport class GraphQlClient extends BaseGraphQLClient {\n\t/**\n\t * @deprecated use execute\n\t */\n\tasync sendRequest<T = unknown>(query: string, options: GraphQlClientRequestOptions = {}): Promise<T> {\n\t\tconsole.debug(query)\n\t\tconst response = await this.doExecute(query, {\n\t\t\t...options,\n\t\t\tapiToken: options.apiTokenOverride ?? options.apiToken,\n\t\t})\n\n\t\tif (response.ok) {\n\t\t\t// It may still have errors (e.g. unfilled fields) but as far as the request goes, it is ok.\n\t\t\treturn await response.json()\n\t\t}\n\n\t\tconst failedRequest: GraphQlClientFailedRequestMetadata = {\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\tresponseText: await response.text(),\n\t\t}\n\n\t\treturn Promise.reject(failedRequest)\n\t}\n\n}\n"],"names":["BaseGraphQLClient"],"mappings":";;;AAaO,MAAM,sBAAsBA,cAAAA,cAAkB;AAAA;AAAA;AAAA;AAAA,EAIpD,MAAM,YAAyB,OAAe,UAAuC,IAAgB;AACpG,YAAQ,MAAM,KAAK;AACnB,UAAM,WAAW,MAAM,KAAK,UAAU,OAAO;AAAA,MAC5C,GAAG;AAAA,MACH,UAAU,QAAQ,oBAAoB,QAAQ;AAAA,IAAA,CAC9C;AAED,QAAI,SAAS,IAAI;AAET,aAAA,MAAM,SAAS;IACvB;AAEA,UAAM,gBAAoD;AAAA,MACzD,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,cAAc,MAAM,SAAS,KAAK;AAAA,IAAA;AAG5B,WAAA,QAAQ,OAAO,aAAa;AAAA,EACpC;AAED;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { GraphQlClient as GraphQlClient$1 } from "@contember/graphql-client";
|
|
2
|
-
class GraphQlClient extends GraphQlClient$1 {
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated use execute
|
|
5
|
-
*/
|
|
6
|
-
async sendRequest(query, options = {}) {
|
|
7
|
-
console.debug(query);
|
|
8
|
-
const response = await this.doExecute(query, {
|
|
9
|
-
...options,
|
|
10
|
-
apiToken: options.apiTokenOverride ?? options.apiToken
|
|
11
|
-
});
|
|
12
|
-
if (response.ok) {
|
|
13
|
-
return await response.json();
|
|
14
|
-
}
|
|
15
|
-
const failedRequest = {
|
|
16
|
-
status: response.status,
|
|
17
|
-
statusText: response.statusText,
|
|
18
|
-
responseText: await response.text()
|
|
19
|
-
};
|
|
20
|
-
return Promise.reject(failedRequest);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
GraphQlClient
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=GraphQlClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQlClient.js","sources":["../../../src/graphQlClient/GraphQlClient.ts"],"sourcesContent":["import { GraphQlClient as BaseGraphQLClient, GraphQlClientRequestOptions as BaseGraphQlClientRequestOptions } from '@contember/graphql-client'\n\nexport interface GraphQlClientRequestOptions extends BaseGraphQlClientRequestOptions {\n\t/**\n\t * @deprecated use apiToken\n\t */\n\tapiTokenOverride?: string\n}\n\nexport type GraphQlClientFailedRequestMetadata = Pick<Response, 'status' | 'statusText'> & {\n\tresponseText: string\n}\n\nexport class GraphQlClient extends BaseGraphQLClient {\n\t/**\n\t * @deprecated use execute\n\t */\n\tasync sendRequest<T = unknown>(query: string, options: GraphQlClientRequestOptions = {}): Promise<T> {\n\t\tconsole.debug(query)\n\t\tconst response = await this.doExecute(query, {\n\t\t\t...options,\n\t\t\tapiToken: options.apiTokenOverride ?? options.apiToken,\n\t\t})\n\n\t\tif (response.ok) {\n\t\t\t// It may still have errors (e.g. unfilled fields) but as far as the request goes, it is ok.\n\t\t\treturn await response.json()\n\t\t}\n\n\t\tconst failedRequest: GraphQlClientFailedRequestMetadata = {\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\tresponseText: await response.text(),\n\t\t}\n\n\t\treturn Promise.reject(failedRequest)\n\t}\n\n}\n"],"names":["BaseGraphQLClient"],"mappings":";AAaO,MAAM,sBAAsBA,gBAAkB;AAAA;AAAA;AAAA;AAAA,EAIpD,MAAM,YAAyB,OAAe,UAAuC,IAAgB;AACpG,YAAQ,MAAM,KAAK;AACnB,UAAM,WAAW,MAAM,KAAK,UAAU,OAAO;AAAA,MAC5C,GAAG;AAAA,MACH,UAAU,QAAQ,oBAAoB,QAAQ;AAAA,IAAA,CAC9C;AAED,QAAI,SAAS,IAAI;AAET,aAAA,MAAM,SAAS;IACvB;AAEA,UAAM,gBAAoD;AAAA,MACzD,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,cAAc,MAAM,SAAS,KAAK;AAAA,IAAA;AAG5B,WAAA,QAAQ,OAAO,aAAa;AAAA,EACpC;AAED;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const formatSystemApiRelativeUrl = (projectSlug) => `/system/${projectSlug}`;
|
|
4
|
-
exports.formatSystemApiRelativeUrl = formatSystemApiRelativeUrl;
|
|
5
|
-
//# sourceMappingURL=formatSystemApiRelativeUrl.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatSystemApiRelativeUrl.cjs","sources":["../../../src/system/formatSystemApiRelativeUrl.ts"],"sourcesContent":["export const formatSystemApiRelativeUrl = (projectSlug: string) => `/system/${projectSlug}`\n"],"names":[],"mappings":";;AAAO,MAAM,6BAA6B,CAAC,gBAAwB,WAAW,WAAW;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatSystemApiRelativeUrl.js","sources":["../../../src/system/formatSystemApiRelativeUrl.ts"],"sourcesContent":["export const formatSystemApiRelativeUrl = (projectSlug: string) => `/system/${projectSlug}`\n"],"names":[],"mappings":"AAAO,MAAM,6BAA6B,CAAC,gBAAwB,WAAW,WAAW;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const loginMutation = `
|
|
4
|
-
mutation($email: String!, $password: String!, $expiration: Int) {
|
|
5
|
-
signIn(email: $email, password: $password, expiration: $expiration) {
|
|
6
|
-
ok
|
|
7
|
-
errors {
|
|
8
|
-
endUserMessage
|
|
9
|
-
code
|
|
10
|
-
}
|
|
11
|
-
result {
|
|
12
|
-
token
|
|
13
|
-
person {
|
|
14
|
-
id
|
|
15
|
-
email
|
|
16
|
-
identity {
|
|
17
|
-
id
|
|
18
|
-
projects {
|
|
19
|
-
project {
|
|
20
|
-
id
|
|
21
|
-
slug
|
|
22
|
-
}
|
|
23
|
-
memberships {
|
|
24
|
-
role
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
exports.loginMutation = loginMutation;
|
|
34
|
-
//# sourceMappingURL=loginMutation.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loginMutation.cjs","sources":["../../../src/tenant/loginMutation.ts"],"sourcesContent":["export interface LoginMutationResponse {\n\tdata: {\n\t\tsignIn: {\n\t\t\tok: boolean\n\t\t\terrors: Array<{\n\t\t\t\tendUserMessage: string | null\n\t\t\t\tcode: string\n\t\t\t}>\n\t\t\tresult: {\n\t\t\t\ttoken: string\n\t\t\t\tperson: {\n\t\t\t\t\tid: string\n\t\t\t\t\temail: string\n\t\t\t\t\tidentity: {\n\t\t\t\t\t\tid: string\n\t\t\t\t\t\tprojects: Array<{\n\t\t\t\t\t\t\tproject: {\n\t\t\t\t\t\t\t\tid: string\n\t\t\t\t\t\t\t\tslug: string\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmemberships: Array<{\n\t\t\t\t\t\t\t\trole: string\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t}>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} | null\n\t\t}\n\t}\n}\n\nexport const loginMutation = `\n\tmutation($email: String!, $password: String!, $expiration: Int) {\n\t\tsignIn(email: $email, password: $password, expiration: $expiration) {\n\t\t\tok\n\t\t\terrors {\n\t\t\t\tendUserMessage\n\t\t\t\tcode\n\t\t\t}\n\t\t\tresult {\n\t\t\t\ttoken\n\t\t\t\tperson {\n\t\t\t\t\tid\n\t\t\t\t\temail\n\t\t\t\t\tidentity {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tprojects {\n\t\t\t\t\t\t\tproject {\n\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmemberships {\n\t\t\t\t\t\t\t\trole\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`\n"],"names":[],"mappings":";;AA+BO,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const loginMutation = `
|
|
2
|
-
mutation($email: String!, $password: String!, $expiration: Int) {
|
|
3
|
-
signIn(email: $email, password: $password, expiration: $expiration) {
|
|
4
|
-
ok
|
|
5
|
-
errors {
|
|
6
|
-
endUserMessage
|
|
7
|
-
code
|
|
8
|
-
}
|
|
9
|
-
result {
|
|
10
|
-
token
|
|
11
|
-
person {
|
|
12
|
-
id
|
|
13
|
-
email
|
|
14
|
-
identity {
|
|
15
|
-
id
|
|
16
|
-
projects {
|
|
17
|
-
project {
|
|
18
|
-
id
|
|
19
|
-
slug
|
|
20
|
-
}
|
|
21
|
-
memberships {
|
|
22
|
-
role
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
export {
|
|
32
|
-
loginMutation
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=loginMutation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loginMutation.js","sources":["../../../src/tenant/loginMutation.ts"],"sourcesContent":["export interface LoginMutationResponse {\n\tdata: {\n\t\tsignIn: {\n\t\t\tok: boolean\n\t\t\terrors: Array<{\n\t\t\t\tendUserMessage: string | null\n\t\t\t\tcode: string\n\t\t\t}>\n\t\t\tresult: {\n\t\t\t\ttoken: string\n\t\t\t\tperson: {\n\t\t\t\t\tid: string\n\t\t\t\t\temail: string\n\t\t\t\t\tidentity: {\n\t\t\t\t\t\tid: string\n\t\t\t\t\t\tprojects: Array<{\n\t\t\t\t\t\t\tproject: {\n\t\t\t\t\t\t\t\tid: string\n\t\t\t\t\t\t\t\tslug: string\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmemberships: Array<{\n\t\t\t\t\t\t\t\trole: string\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t}>\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} | null\n\t\t}\n\t}\n}\n\nexport const loginMutation = `\n\tmutation($email: String!, $password: String!, $expiration: Int) {\n\t\tsignIn(email: $email, password: $password, expiration: $expiration) {\n\t\t\tok\n\t\t\terrors {\n\t\t\t\tendUserMessage\n\t\t\t\tcode\n\t\t\t}\n\t\t\tresult {\n\t\t\t\ttoken\n\t\t\t\tperson {\n\t\t\t\t\tid\n\t\t\t\t\temail\n\t\t\t\t\tidentity {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tprojects {\n\t\t\t\t\t\t\tproject {\n\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\tslug\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmemberships {\n\t\t\t\t\t\t\t\trole\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n`\n"],"names":[],"mappings":"AA+BO,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tenantApiRelativeUrl.cjs","sources":["../../../src/tenant/tenantApiRelativeUrl.ts"],"sourcesContent":["export const tenantApiRelativeUrl = '/tenant'\n"],"names":[],"mappings":";;AAAO,MAAM,uBAAuB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tenantApiRelativeUrl.js","sources":["../../../src/tenant/tenantApiRelativeUrl.ts"],"sourcesContent":["export const tenantApiRelativeUrl = '/tenant'\n"],"names":[],"mappings":"AAAO,MAAM,uBAAuB;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const tenantErrorMessages = {
|
|
4
|
-
TOO_WEAK: "Password is too weak.",
|
|
5
|
-
EMAIL_ALREADY_EXISTS: "Email already exists.",
|
|
6
|
-
UNKNOWN_EMAIL: "Unknown email.",
|
|
7
|
-
INVALID_PASSWORD: "Password is invalid.",
|
|
8
|
-
ALREADY_MEMBER: "User is already a member of this project."
|
|
9
|
-
};
|
|
10
|
-
const getTenantErrorMessage = (errorCode) => {
|
|
11
|
-
if (errorCode in tenantErrorMessages) {
|
|
12
|
-
return tenantErrorMessages[errorCode];
|
|
13
|
-
}
|
|
14
|
-
return `Unknown error occurred. [${errorCode}]`;
|
|
15
|
-
};
|
|
16
|
-
exports.getTenantErrorMessage = getTenantErrorMessage;
|
|
17
|
-
exports.tenantErrorMessages = tenantErrorMessages;
|
|
18
|
-
//# sourceMappingURL=tenantErrorMessages.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tenantErrorMessages.cjs","sources":["../../../src/tenant/tenantErrorMessages.ts"],"sourcesContent":["export const tenantErrorMessages: { [key: string]: string } = {\n\tTOO_WEAK: 'Password is too weak.',\n\tEMAIL_ALREADY_EXISTS: 'Email already exists.',\n\tUNKNOWN_EMAIL: 'Unknown email.',\n\tINVALID_PASSWORD: 'Password is invalid.',\n\tALREADY_MEMBER: 'User is already a member of this project.',\n}\n\nexport const getTenantErrorMessage = (errorCode: string): string => {\n\tif (errorCode in tenantErrorMessages) {\n\t\treturn tenantErrorMessages[errorCode]\n\t}\n\treturn `Unknown error occurred. [${errorCode}]`\n}\n"],"names":[],"mappings":";;AAAO,MAAM,sBAAiD;AAAA,EAC7D,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,gBAAgB;AACjB;AAEa,MAAA,wBAAwB,CAAC,cAA8B;AACnE,MAAI,aAAa,qBAAqB;AACrC,WAAO,oBAAoB,SAAS;AAAA,EACrC;AACA,SAAO,4BAA4B,SAAS;AAC7C;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const tenantErrorMessages = {
|
|
2
|
-
TOO_WEAK: "Password is too weak.",
|
|
3
|
-
EMAIL_ALREADY_EXISTS: "Email already exists.",
|
|
4
|
-
UNKNOWN_EMAIL: "Unknown email.",
|
|
5
|
-
INVALID_PASSWORD: "Password is invalid.",
|
|
6
|
-
ALREADY_MEMBER: "User is already a member of this project."
|
|
7
|
-
};
|
|
8
|
-
const getTenantErrorMessage = (errorCode) => {
|
|
9
|
-
if (errorCode in tenantErrorMessages) {
|
|
10
|
-
return tenantErrorMessages[errorCode];
|
|
11
|
-
}
|
|
12
|
-
return `Unknown error occurred. [${errorCode}]`;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
getTenantErrorMessage,
|
|
16
|
-
tenantErrorMessages
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=tenantErrorMessages.js.map
|