@webiny/sdk 6.3.0-beta.4 → 6.4.0-beta.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.
Files changed (115) hide show
  1. package/BaseError.js +8 -7
  2. package/BaseError.js.map +1 -1
  3. package/CmsSdk.js +34 -33
  4. package/CmsSdk.js.map +1 -1
  5. package/FileManagerSdk.js +50 -49
  6. package/FileManagerSdk.js.map +1 -1
  7. package/LanguagesSdk.js +10 -9
  8. package/LanguagesSdk.js.map +1 -1
  9. package/Result.js +40 -134
  10. package/Result.js.map +1 -1
  11. package/TasksSdk.js +26 -25
  12. package/TasksSdk.js.map +1 -1
  13. package/TenantManagerSdk.js +26 -25
  14. package/TenantManagerSdk.js.map +1 -1
  15. package/Webiny.js +24 -26
  16. package/Webiny.js.map +1 -1
  17. package/errors.js +31 -48
  18. package/errors.js.map +1 -1
  19. package/index.js +1 -21
  20. package/methods/cms/cmsTypes.js +0 -3
  21. package/methods/cms/createEntry.js +14 -39
  22. package/methods/cms/createEntry.js.map +1 -1
  23. package/methods/cms/deleteEntryRevision.js +12 -30
  24. package/methods/cms/deleteEntryRevision.js.map +1 -1
  25. package/methods/cms/getEntry.js +15 -36
  26. package/methods/cms/getEntry.js.map +1 -1
  27. package/methods/cms/listEntries.js +22 -51
  28. package/methods/cms/listEntries.js.map +1 -1
  29. package/methods/cms/publishEntryRevision.js +14 -33
  30. package/methods/cms/publishEntryRevision.js.map +1 -1
  31. package/methods/cms/schemas.js +39 -35
  32. package/methods/cms/schemas.js.map +1 -1
  33. package/methods/cms/unpublishEntryRevision.js +14 -33
  34. package/methods/cms/unpublishEntryRevision.js.map +1 -1
  35. package/methods/cms/updateEntryRevision.js +15 -42
  36. package/methods/cms/updateEntryRevision.js.map +1 -1
  37. package/methods/executeGraphQL.js +38 -41
  38. package/methods/executeGraphQL.js.map +1 -1
  39. package/methods/fileManager/buildFieldsSelection.js +25 -67
  40. package/methods/fileManager/buildFieldsSelection.js.map +1 -1
  41. package/methods/fileManager/completeMultiPartUpload.js +12 -29
  42. package/methods/fileManager/completeMultiPartUpload.js.map +1 -1
  43. package/methods/fileManager/createFile.js +61 -125
  44. package/methods/fileManager/createFile.js.map +1 -1
  45. package/methods/fileManager/createFiles.js +41 -76
  46. package/methods/fileManager/createFiles.js.map +1 -1
  47. package/methods/fileManager/createMultiPartUpload.js +12 -29
  48. package/methods/fileManager/createMultiPartUpload.js.map +1 -1
  49. package/methods/fileManager/deleteFile.js +11 -26
  50. package/methods/fileManager/deleteFile.js.map +1 -1
  51. package/methods/fileManager/fileManagerTypes.js +19 -18
  52. package/methods/fileManager/fileManagerTypes.js.map +1 -1
  53. package/methods/fileManager/getFile.js +15 -30
  54. package/methods/fileManager/getFile.js.map +1 -1
  55. package/methods/fileManager/getPresignedPostPayload.js +17 -40
  56. package/methods/fileManager/getPresignedPostPayload.js.map +1 -1
  57. package/methods/fileManager/getPresignedPostPayloads.js +17 -32
  58. package/methods/fileManager/getPresignedPostPayloads.js.map +1 -1
  59. package/methods/fileManager/listFiles.js +22 -45
  60. package/methods/fileManager/listFiles.js.map +1 -1
  61. package/methods/fileManager/listTags.js +11 -25
  62. package/methods/fileManager/listTags.js.map +1 -1
  63. package/methods/fileManager/schemas.js +15 -14
  64. package/methods/fileManager/schemas.js.map +1 -1
  65. package/methods/fileManager/updateFile.js +12 -29
  66. package/methods/fileManager/updateFile.js.map +1 -1
  67. package/methods/fileManager/utils/fileTypeDetection.js +10 -12
  68. package/methods/fileManager/utils/fileTypeDetection.js.map +1 -1
  69. package/methods/fileManager/utils/uploadLargeFile.js +86 -165
  70. package/methods/fileManager/utils/uploadLargeFile.js.map +1 -1
  71. package/methods/fileManager/utils/uploadToS3.js +41 -94
  72. package/methods/fileManager/utils/uploadToS3.js.map +1 -1
  73. package/methods/languages/listLanguages.js +8 -11
  74. package/methods/languages/listLanguages.js.map +1 -1
  75. package/methods/tasks/abortTask.js +11 -17
  76. package/methods/tasks/abortTask.js.map +1 -1
  77. package/methods/tasks/listDefinitions.js +8 -11
  78. package/methods/tasks/listDefinitions.js.map +1 -1
  79. package/methods/tasks/listLogs.js +10 -15
  80. package/methods/tasks/listLogs.js.map +1 -1
  81. package/methods/tasks/listTasks.js +8 -11
  82. package/methods/tasks/listTasks.js.map +1 -1
  83. package/methods/tasks/schemas.js +11 -10
  84. package/methods/tasks/schemas.js.map +1 -1
  85. package/methods/tasks/taskTypes.js +0 -3
  86. package/methods/tasks/triggerTask.js +11 -17
  87. package/methods/tasks/triggerTask.js.map +1 -1
  88. package/methods/tenantManager/createTenant.js +10 -24
  89. package/methods/tenantManager/createTenant.js.map +1 -1
  90. package/methods/tenantManager/disableTenant.js +10 -24
  91. package/methods/tenantManager/disableTenant.js.map +1 -1
  92. package/methods/tenantManager/enableTenant.js +10 -24
  93. package/methods/tenantManager/enableTenant.js.map +1 -1
  94. package/methods/tenantManager/getCurrentTenant.js +8 -18
  95. package/methods/tenantManager/getCurrentTenant.js.map +1 -1
  96. package/methods/tenantManager/installTenant.js +10 -24
  97. package/methods/tenantManager/installTenant.js.map +1 -1
  98. package/methods/tenantManager/schemas.js +13 -12
  99. package/methods/tenantManager/schemas.js.map +1 -1
  100. package/methods/tenantManager/tenantManagerTypes.js +0 -3
  101. package/package.json +5 -5
  102. package/types.js +0 -3
  103. package/utils/createMethod.js +6 -24
  104. package/utils/createMethod.js.map +1 -1
  105. package/utils/platform.js +3 -2
  106. package/utils/platform.js.map +1 -1
  107. package/utils/transformFieldErrors.js +14 -33
  108. package/utils/transformFieldErrors.js.map +1 -1
  109. package/utils/validateParams.js +13 -16
  110. package/utils/validateParams.js.map +1 -1
  111. package/index.js.map +0 -1
  112. package/methods/cms/cmsTypes.js.map +0 -1
  113. package/methods/tasks/taskTypes.js.map +0 -1
  114. package/methods/tenantManager/tenantManagerTypes.js.map +0 -1
  115. package/types.js.map +0 -1
package/BaseError.js CHANGED
@@ -1,10 +1,11 @@
1
- export class BaseError extends Error {
2
- constructor(input, options) {
3
- super(input.message);
4
- this.message = input.message;
5
- this.stack = options?.stack;
6
- this.data = input.data;
7
- }
1
+ class BaseError extends Error {
2
+ constructor(input, options){
3
+ super(input.message);
4
+ this.message = input.message;
5
+ this.stack = options?.stack;
6
+ this.data = input.data;
7
+ }
8
8
  }
9
+ export { BaseError };
9
10
 
10
11
  //# sourceMappingURL=BaseError.js.map
package/BaseError.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["BaseError","Error","constructor","input","options","message","stack","data"],"sources":["BaseError.ts"],"sourcesContent":["export interface ErrorOptions {\n stack?: string;\n}\n\ntype ErrorDataWithOptionalData<TData> = TData extends void\n ? { message: string; data?: never }\n : { message: string; data: TData };\n\nexport abstract class BaseError<TData = void> extends Error {\n public abstract readonly code: string;\n public readonly data: TData extends void ? undefined : TData;\n public override readonly message: string;\n\n protected constructor(input: ErrorDataWithOptionalData<TData>, options?: ErrorOptions) {\n super(input.message);\n this.message = input.message;\n this.stack = options?.stack;\n this.data = input.data as any;\n }\n}\n"],"mappings":"AAQA,OAAO,MAAeA,SAAS,SAAuBC,KAAK,CAAC;EAK9CC,WAAWA,CAACC,KAAuC,EAAEC,OAAsB,EAAE;IACnF,KAAK,CAACD,KAAK,CAACE,OAAO,CAAC;IACpB,IAAI,CAACA,OAAO,GAAGF,KAAK,CAACE,OAAO;IAC5B,IAAI,CAACC,KAAK,GAAGF,OAAO,EAAEE,KAAK;IAC3B,IAAI,CAACC,IAAI,GAAGJ,KAAK,CAACI,IAAW;EACjC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"BaseError.js","sources":["../src/BaseError.ts"],"sourcesContent":["export interface ErrorOptions {\n stack?: string;\n}\n\ntype ErrorDataWithOptionalData<TData> = TData extends void\n ? { message: string; data?: never }\n : { message: string; data: TData };\n\nexport abstract class BaseError<TData = void> extends Error {\n public abstract readonly code: string;\n public readonly data: TData extends void ? undefined : TData;\n public override readonly message: string;\n\n protected constructor(input: ErrorDataWithOptionalData<TData>, options?: ErrorOptions) {\n super(input.message);\n this.message = input.message;\n this.stack = options?.stack;\n this.data = input.data as any;\n }\n}\n"],"names":["BaseError","Error","input","options"],"mappings":"AAQO,MAAeA,kBAAgCC;IAKlD,YAAsBC,KAAuC,EAAEC,OAAsB,CAAE;QACnF,KAAK,CAACD,MAAM,OAAO;QACnB,IAAI,CAAC,OAAO,GAAGA,MAAM,OAAO;QAC5B,IAAI,CAAC,KAAK,GAAGC,SAAS;QACtB,IAAI,CAAC,IAAI,GAAGD,MAAM,IAAI;IAC1B;AACJ"}
package/CmsSdk.js CHANGED
@@ -1,36 +1,37 @@
1
- import { getEntry as getEntryFn } from "./methods/cms/getEntry.js";
2
- import { listEntries as listEntriesFn } from "./methods/cms/listEntries.js";
3
- import { createEntry as createEntryFn } from "./methods/cms/createEntry.js";
4
- import { updateEntryRevision as updateEntryRevisionFn } from "./methods/cms/updateEntryRevision.js";
5
- import { deleteEntryRevision as deleteEntryRevisionFn } from "./methods/cms/deleteEntryRevision.js";
6
- import { publishEntryRevision as publishEntryRevisionFn } from "./methods/cms/publishEntryRevision.js";
7
- import { unpublishEntryRevision as unpublishEntryRevisionFn } from "./methods/cms/unpublishEntryRevision.js";
8
- export class CmsSdk {
9
- constructor(config) {
10
- this.config = config;
11
- this.fetchFn = config.fetch || fetch;
12
- }
13
- async getEntry(params) {
14
- return getEntryFn(this.config, this.fetchFn, params);
15
- }
16
- async listEntries(params) {
17
- return listEntriesFn(this.config, this.fetchFn, params);
18
- }
19
- async createEntry(params) {
20
- return createEntryFn(this.config, this.fetchFn, params);
21
- }
22
- async updateEntryRevision(params) {
23
- return updateEntryRevisionFn(this.config, this.fetchFn, params);
24
- }
25
- async deleteEntryRevision(params) {
26
- return deleteEntryRevisionFn(this.config, this.fetchFn, params);
27
- }
28
- async publishEntryRevision(params) {
29
- return publishEntryRevisionFn(this.config, this.fetchFn, params);
30
- }
31
- async unpublishEntryRevision(params) {
32
- return unpublishEntryRevisionFn(this.config, this.fetchFn, params);
33
- }
1
+ import { getEntry } from "./methods/cms/getEntry.js";
2
+ import { listEntries } from "./methods/cms/listEntries.js";
3
+ import { createEntry } from "./methods/cms/createEntry.js";
4
+ import { updateEntryRevision } from "./methods/cms/updateEntryRevision.js";
5
+ import { deleteEntryRevision } from "./methods/cms/deleteEntryRevision.js";
6
+ import { publishEntryRevision } from "./methods/cms/publishEntryRevision.js";
7
+ import { unpublishEntryRevision } from "./methods/cms/unpublishEntryRevision.js";
8
+ class CmsSdk {
9
+ constructor(config){
10
+ this.config = config;
11
+ this.fetchFn = config.fetch || fetch;
12
+ }
13
+ async getEntry(params) {
14
+ return getEntry(this.config, this.fetchFn, params);
15
+ }
16
+ async listEntries(params) {
17
+ return listEntries(this.config, this.fetchFn, params);
18
+ }
19
+ async createEntry(params) {
20
+ return createEntry(this.config, this.fetchFn, params);
21
+ }
22
+ async updateEntryRevision(params) {
23
+ return updateEntryRevision(this.config, this.fetchFn, params);
24
+ }
25
+ async deleteEntryRevision(params) {
26
+ return deleteEntryRevision(this.config, this.fetchFn, params);
27
+ }
28
+ async publishEntryRevision(params) {
29
+ return publishEntryRevision(this.config, this.fetchFn, params);
30
+ }
31
+ async unpublishEntryRevision(params) {
32
+ return unpublishEntryRevision(this.config, this.fetchFn, params);
33
+ }
34
34
  }
35
+ export { CmsSdk };
35
36
 
36
37
  //# sourceMappingURL=CmsSdk.js.map
package/CmsSdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["getEntry","getEntryFn","listEntries","listEntriesFn","createEntry","createEntryFn","updateEntryRevision","updateEntryRevisionFn","deleteEntryRevision","deleteEntryRevisionFn","publishEntryRevision","publishEntryRevisionFn","unpublishEntryRevision","unpublishEntryRevisionFn","CmsSdk","constructor","config","fetchFn","fetch","params"],"sources":["CmsSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./methods/cms/cmsTypes.js\";\nimport type { GetEntryParams } from \"./methods/cms/getEntry.js\";\nimport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\nimport type { CreateEntryParams, CreateCmsEntryData } from \"./methods/cms/createEntry.js\";\nimport type {\n UpdateEntryRevisionParams,\n UpdateCmsEntryData\n} from \"./methods/cms/updateEntryRevision.js\";\nimport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\nimport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\nimport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\nimport type { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { getEntry as getEntryFn } from \"./methods/cms/getEntry.js\";\nimport { listEntries as listEntriesFn } from \"./methods/cms/listEntries.js\";\nimport { createEntry as createEntryFn } from \"./methods/cms/createEntry.js\";\nimport { updateEntryRevision as updateEntryRevisionFn } from \"./methods/cms/updateEntryRevision.js\";\nimport { deleteEntryRevision as deleteEntryRevisionFn } from \"./methods/cms/deleteEntryRevision.js\";\nimport { publishEntryRevision as publishEntryRevisionFn } from \"./methods/cms/publishEntryRevision.js\";\nimport { unpublishEntryRevision as unpublishEntryRevisionFn } from \"./methods/cms/unpublishEntryRevision.js\";\n\nexport class CmsSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n params: GetEntryParams\n ): Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return getEntryFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async listEntries<TValues extends CmsEntryValues = CmsEntryValues>(\n params: ListEntriesParams\n ): Promise<\n Result<ListEntriesResult<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return listEntriesFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async createEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n params: CreateEntryParams<TValues>\n ): Promise<\n Result<CreateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return createEntryFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: UpdateEntryRevisionParams<TValues>\n ): Promise<\n Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return updateEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async deleteEntryRevision(\n params: DeleteEntryRevisionParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return deleteEntryRevisionFn(this.config, this.fetchFn, params);\n }\n\n async publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: PublishEntryRevisionParams\n ): Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return publishEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: UnpublishEntryRevisionParams\n ): Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return unpublishEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n}\n"],"mappings":"AAcA,SAASA,QAAQ,IAAIC,UAAU;AAC/B,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,mBAAmB,IAAIC,qBAAqB;AACrD,SAASC,mBAAmB,IAAIC,qBAAqB;AACrD,SAASC,oBAAoB,IAAIC,sBAAsB;AACvD,SAASC,sBAAsB,IAAIC,wBAAwB;AAE3D,OAAO,MAAMC,MAAM,CAAC;EAIhBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAMlB,QAAQA,CACVmB,MAAsB,EAGxB;IACE,OAAOlB,UAAU,CAAU,IAAI,CAACe,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACjE;EAEA,MAAMjB,WAAWA,CACbiB,MAAyB,EAG3B;IACE,OAAOhB,aAAa,CAAU,IAAI,CAACa,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACpE;EAEA,MAAMf,WAAWA,CACbe,MAAkC,EAGpC;IACE,OAAOd,aAAa,CAAU,IAAI,CAACW,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACpE;EAEA,MAAMb,mBAAmBA,CACrBa,MAA0C,EAG5C;IACE,OAAOZ,qBAAqB,CAAU,IAAI,CAACS,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC5E;EAEA,MAAMX,mBAAmBA,CACrBW,MAAiC,EAC8C;IAC/E,OAAOV,qBAAqB,CAAC,IAAI,CAACO,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACnE;EAEA,MAAMT,oBAAoBA,CACtBS,MAAkC,EAGpC;IACE,OAAOR,sBAAsB,CAAU,IAAI,CAACK,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC7E;EAEA,MAAMP,sBAAsBA,CACxBO,MAAoC,EAGtC;IACE,OAAON,wBAAwB,CAAU,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC/E;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"CmsSdk.js","sources":["../src/CmsSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { CmsEntryValues, CmsEntryData } from \"./methods/cms/cmsTypes.js\";\nimport type { GetEntryParams } from \"./methods/cms/getEntry.js\";\nimport type { ListEntriesParams, ListEntriesResult } from \"./methods/cms/listEntries.js\";\nimport type { CreateEntryParams, CreateCmsEntryData } from \"./methods/cms/createEntry.js\";\nimport type {\n UpdateEntryRevisionParams,\n UpdateCmsEntryData\n} from \"./methods/cms/updateEntryRevision.js\";\nimport type { DeleteEntryRevisionParams } from \"./methods/cms/deleteEntryRevision.js\";\nimport type { PublishEntryRevisionParams } from \"./methods/cms/publishEntryRevision.js\";\nimport type { UnpublishEntryRevisionParams } from \"./methods/cms/unpublishEntryRevision.js\";\nimport type { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { getEntry as getEntryFn } from \"./methods/cms/getEntry.js\";\nimport { listEntries as listEntriesFn } from \"./methods/cms/listEntries.js\";\nimport { createEntry as createEntryFn } from \"./methods/cms/createEntry.js\";\nimport { updateEntryRevision as updateEntryRevisionFn } from \"./methods/cms/updateEntryRevision.js\";\nimport { deleteEntryRevision as deleteEntryRevisionFn } from \"./methods/cms/deleteEntryRevision.js\";\nimport { publishEntryRevision as publishEntryRevisionFn } from \"./methods/cms/publishEntryRevision.js\";\nimport { unpublishEntryRevision as unpublishEntryRevisionFn } from \"./methods/cms/unpublishEntryRevision.js\";\n\nexport class CmsSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n params: GetEntryParams\n ): Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return getEntryFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async listEntries<TValues extends CmsEntryValues = CmsEntryValues>(\n params: ListEntriesParams\n ): Promise<\n Result<ListEntriesResult<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return listEntriesFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async createEntry<TValues extends CmsEntryValues = CmsEntryValues>(\n params: CreateEntryParams<TValues>\n ): Promise<\n Result<CreateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return createEntryFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async updateEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: UpdateEntryRevisionParams<TValues>\n ): Promise<\n Result<UpdateCmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return updateEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async deleteEntryRevision(\n params: DeleteEntryRevisionParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError | ValidationError>> {\n return deleteEntryRevisionFn(this.config, this.fetchFn, params);\n }\n\n async publishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: PublishEntryRevisionParams\n ): Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return publishEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n\n async unpublishEntryRevision<TValues extends CmsEntryValues = CmsEntryValues>(\n params: UnpublishEntryRevisionParams\n ): Promise<\n Result<CmsEntryData<TValues>, HttpError | ApiError | NetworkError | ValidationError>\n > {\n return unpublishEntryRevisionFn<TValues>(this.config, this.fetchFn, params);\n }\n}\n"],"names":["CmsSdk","config","fetch","params","getEntryFn","listEntriesFn","createEntryFn","updateEntryRevisionFn","deleteEntryRevisionFn","publishEntryRevisionFn","unpublishEntryRevisionFn"],"mappings":";;;;;;;AAsBO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,SACFC,MAAsB,EAGxB;QACE,OAAOC,SAAoB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAED;IAC1D;IAEA,MAAM,YACFA,MAAyB,EAG3B;QACE,OAAOE,YAAuB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEF;IAC7D;IAEA,MAAM,YACFA,MAAkC,EAGpC;QACE,OAAOG,YAAuB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEH;IAC7D;IAEA,MAAM,oBACFA,MAA0C,EAG5C;QACE,OAAOI,oBAA+B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEJ;IACrE;IAEA,MAAM,oBACFA,MAAiC,EAC8C;QAC/E,OAAOK,oBAAsB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEL;IAC5D;IAEA,MAAM,qBACFA,MAAkC,EAGpC;QACE,OAAOM,qBAAgC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEN;IACtE;IAEA,MAAM,uBACFA,MAAoC,EAGtC;QACE,OAAOO,uBAAkC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEP;IACxE;AACJ"}
package/FileManagerSdk.js CHANGED
@@ -1,52 +1,53 @@
1
- import { getFile as getFileFn } from "./methods/fileManager/getFile.js";
2
- import { listFiles as listFilesFn } from "./methods/fileManager/listFiles.js";
3
- import { createFile as createFileFn } from "./methods/fileManager/createFile.js";
4
- import { createFiles as createFilesFn } from "./methods/fileManager/createFiles.js";
5
- import { updateFile as updateFileFn } from "./methods/fileManager/updateFile.js";
6
- import { deleteFile as deleteFileFn } from "./methods/fileManager/deleteFile.js";
7
- import { listTags as listTagsFn } from "./methods/fileManager/listTags.js";
8
- import { getPresignedPostPayload as getPresignedPostPayloadFn } from "./methods/fileManager/getPresignedPostPayload.js";
9
- import { getPresignedPostPayloads as getPresignedPostPayloadsFn } from "./methods/fileManager/getPresignedPostPayloads.js";
10
- import { createMultiPartUpload as createMultiPartUploadFn } from "./methods/fileManager/createMultiPartUpload.js";
11
- import { completeMultiPartUpload as completeMultiPartUploadFn } from "./methods/fileManager/completeMultiPartUpload.js";
12
- export class FileManagerSdk {
13
- constructor(config) {
14
- this.config = config;
15
- this.fetchFn = config.fetch || fetch;
16
- }
17
- async getFile(params) {
18
- return getFileFn(this.config, this.fetchFn, params);
19
- }
20
- async listFiles(params) {
21
- return listFilesFn(this.config, this.fetchFn, params);
22
- }
23
- async createFile(params) {
24
- return createFileFn(this.config, this.fetchFn, params);
25
- }
26
- async createFiles(params) {
27
- return createFilesFn(this.config, this.fetchFn, params);
28
- }
29
- async updateFile(params) {
30
- return updateFileFn(this.config, this.fetchFn, params);
31
- }
32
- async deleteFile(params) {
33
- return deleteFileFn(this.config, this.fetchFn, params);
34
- }
35
- async listTags(params) {
36
- return listTagsFn(this.config, this.fetchFn, params);
37
- }
38
- async getPresignedPostPayload(params) {
39
- return getPresignedPostPayloadFn(this.config, this.fetchFn, params);
40
- }
41
- async getPresignedPostPayloads(params) {
42
- return getPresignedPostPayloadsFn(this.config, this.fetchFn, params);
43
- }
44
- async createMultiPartUpload(params) {
45
- return createMultiPartUploadFn(this.config, this.fetchFn, params);
46
- }
47
- async completeMultiPartUpload(params) {
48
- return completeMultiPartUploadFn(this.config, this.fetchFn, params);
49
- }
1
+ import { getFile } from "./methods/fileManager/getFile.js";
2
+ import { listFiles } from "./methods/fileManager/listFiles.js";
3
+ import { createFile } from "./methods/fileManager/createFile.js";
4
+ import { createFiles } from "./methods/fileManager/createFiles.js";
5
+ import { updateFile } from "./methods/fileManager/updateFile.js";
6
+ import { deleteFile } from "./methods/fileManager/deleteFile.js";
7
+ import { listTags } from "./methods/fileManager/listTags.js";
8
+ import { getPresignedPostPayload } from "./methods/fileManager/getPresignedPostPayload.js";
9
+ import { getPresignedPostPayloads } from "./methods/fileManager/getPresignedPostPayloads.js";
10
+ import { createMultiPartUpload } from "./methods/fileManager/createMultiPartUpload.js";
11
+ import { completeMultiPartUpload } from "./methods/fileManager/completeMultiPartUpload.js";
12
+ class FileManagerSdk {
13
+ constructor(config){
14
+ this.config = config;
15
+ this.fetchFn = config.fetch || fetch;
16
+ }
17
+ async getFile(params) {
18
+ return getFile(this.config, this.fetchFn, params);
19
+ }
20
+ async listFiles(params) {
21
+ return listFiles(this.config, this.fetchFn, params);
22
+ }
23
+ async createFile(params) {
24
+ return createFile(this.config, this.fetchFn, params);
25
+ }
26
+ async createFiles(params) {
27
+ return createFiles(this.config, this.fetchFn, params);
28
+ }
29
+ async updateFile(params) {
30
+ return updateFile(this.config, this.fetchFn, params);
31
+ }
32
+ async deleteFile(params) {
33
+ return deleteFile(this.config, this.fetchFn, params);
34
+ }
35
+ async listTags(params) {
36
+ return listTags(this.config, this.fetchFn, params);
37
+ }
38
+ async getPresignedPostPayload(params) {
39
+ return getPresignedPostPayload(this.config, this.fetchFn, params);
40
+ }
41
+ async getPresignedPostPayloads(params) {
42
+ return getPresignedPostPayloads(this.config, this.fetchFn, params);
43
+ }
44
+ async createMultiPartUpload(params) {
45
+ return createMultiPartUpload(this.config, this.fetchFn, params);
46
+ }
47
+ async completeMultiPartUpload(params) {
48
+ return completeMultiPartUpload(this.config, this.fetchFn, params);
49
+ }
50
50
  }
51
+ export { FileManagerSdk };
51
52
 
52
53
  //# sourceMappingURL=FileManagerSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getFile","getFileFn","listFiles","listFilesFn","createFile","createFileFn","createFiles","createFilesFn","updateFile","updateFileFn","deleteFile","deleteFileFn","listTags","listTagsFn","getPresignedPostPayload","getPresignedPostPayloadFn","getPresignedPostPayloads","getPresignedPostPayloadsFn","createMultiPartUpload","createMultiPartUploadFn","completeMultiPartUpload","completeMultiPartUploadFn","FileManagerSdk","constructor","config","fetchFn","fetch","params"],"sources":["FileManagerSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type {\n FmFile,\n FmTag,\n PresignedPostPayloadResponse\n} from \"./methods/fileManager/fileManagerTypes.js\";\nimport type { GetFileParams } from \"./methods/fileManager/getFile.js\";\nimport type { ListFilesParams, ListFilesResult } from \"./methods/fileManager/listFiles.js\";\nimport type { CreateFileParams } from \"./methods/fileManager/createFile.js\";\nimport type { CreateFilesParams, CreateFilesResult } from \"./methods/fileManager/createFiles.js\";\nimport type { UpdateFileParams } from \"./methods/fileManager/updateFile.js\";\nimport type { DeleteFileParams } from \"./methods/fileManager/deleteFile.js\";\nimport type { ListTagsParams } from \"./methods/fileManager/listTags.js\";\nimport type { GetPresignedPostPayloadParams } from \"./methods/fileManager/getPresignedPostPayload.js\";\nimport type { GetPresignedPostPayloadsParams } from \"./methods/fileManager/getPresignedPostPayloads.js\";\nimport type {\n CreateMultiPartUploadParams,\n MultiPartUploadResponse\n} from \"./methods/fileManager/createMultiPartUpload.js\";\nimport type { CompleteMultiPartUploadParams } from \"./methods/fileManager/completeMultiPartUpload.js\";\nimport type { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { getFile as getFileFn } from \"./methods/fileManager/getFile.js\";\nimport { listFiles as listFilesFn } from \"./methods/fileManager/listFiles.js\";\nimport { createFile as createFileFn } from \"./methods/fileManager/createFile.js\";\nimport { createFiles as createFilesFn } from \"./methods/fileManager/createFiles.js\";\nimport { updateFile as updateFileFn } from \"./methods/fileManager/updateFile.js\";\nimport { deleteFile as deleteFileFn } from \"./methods/fileManager/deleteFile.js\";\nimport { listTags as listTagsFn } from \"./methods/fileManager/listTags.js\";\nimport { getPresignedPostPayload as getPresignedPostPayloadFn } from \"./methods/fileManager/getPresignedPostPayload.js\";\nimport { getPresignedPostPayloads as getPresignedPostPayloadsFn } from \"./methods/fileManager/getPresignedPostPayloads.js\";\nimport { createMultiPartUpload as createMultiPartUploadFn } from \"./methods/fileManager/createMultiPartUpload.js\";\nimport { completeMultiPartUpload as completeMultiPartUploadFn } from \"./methods/fileManager/completeMultiPartUpload.js\";\n\nexport class FileManagerSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getFile(\n params: GetFileParams\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError | ValidationError>> {\n return getFileFn(this.config, this.fetchFn, params);\n }\n\n async listFiles(\n params: ListFilesParams\n ): Promise<Result<ListFilesResult, HttpError | ApiError | NetworkError | ValidationError>> {\n return listFilesFn(this.config, this.fetchFn, params);\n }\n\n async createFile(\n params: CreateFileParams\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> {\n return createFileFn(this.config, this.fetchFn, params);\n }\n\n async createFiles(\n params: CreateFilesParams\n ): Promise<Result<CreateFilesResult, HttpError | ApiError | NetworkError>> {\n return createFilesFn(this.config, this.fetchFn, params);\n }\n\n async updateFile(\n params: UpdateFileParams\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError | ValidationError>> {\n return updateFileFn(this.config, this.fetchFn, params);\n }\n\n async deleteFile(\n params: DeleteFileParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError>> {\n return deleteFileFn(this.config, this.fetchFn, params);\n }\n\n async listTags(\n params?: ListTagsParams\n ): Promise<Result<FmTag[], HttpError | ApiError | NetworkError>> {\n return listTagsFn(this.config, this.fetchFn, params);\n }\n\n async getPresignedPostPayload(\n params: GetPresignedPostPayloadParams\n ): Promise<Result<PresignedPostPayloadResponse, HttpError | ApiError | NetworkError>> {\n return getPresignedPostPayloadFn(this.config, this.fetchFn, params);\n }\n\n async getPresignedPostPayloads(\n params: GetPresignedPostPayloadsParams\n ): Promise<Result<PresignedPostPayloadResponse[], HttpError | ApiError | NetworkError>> {\n return getPresignedPostPayloadsFn(this.config, this.fetchFn, params);\n }\n\n async createMultiPartUpload(\n params: CreateMultiPartUploadParams\n ): Promise<Result<MultiPartUploadResponse, HttpError | ApiError | NetworkError>> {\n return createMultiPartUploadFn(this.config, this.fetchFn, params);\n }\n\n async completeMultiPartUpload(\n params: CompleteMultiPartUploadParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError>> {\n return completeMultiPartUploadFn(this.config, this.fetchFn, params);\n }\n}\n"],"mappings":"AAsBA,SAASA,OAAO,IAAIC,SAAS;AAC7B,SAASC,SAAS,IAAIC,WAAW;AACjC,SAASC,UAAU,IAAIC,YAAY;AACnC,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,UAAU,IAAIC,YAAY;AACnC,SAASC,UAAU,IAAIC,YAAY;AACnC,SAASC,QAAQ,IAAIC,UAAU;AAC/B,SAASC,uBAAuB,IAAIC,yBAAyB;AAC7D,SAASC,wBAAwB,IAAIC,0BAA0B;AAC/D,SAASC,qBAAqB,IAAIC,uBAAuB;AACzD,SAASC,uBAAuB,IAAIC,yBAAyB;AAE7D,OAAO,MAAMC,cAAc,CAAC;EAIxBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAM1B,OAAOA,CACT2B,MAAqB,EACyD;IAC9E,OAAO1B,SAAS,CAAC,IAAI,CAACuB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACvD;EAEA,MAAMzB,SAASA,CACXyB,MAAuB,EACgE;IACvF,OAAOxB,WAAW,CAAC,IAAI,CAACqB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACzD;EAEA,MAAMvB,UAAUA,CACZuB,MAAwB,EACoC;IAC5D,OAAOtB,YAAY,CAAC,IAAI,CAACmB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC1D;EAEA,MAAMrB,WAAWA,CACbqB,MAAyB,EAC8C;IACvE,OAAOpB,aAAa,CAAC,IAAI,CAACiB,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC3D;EAEA,MAAMnB,UAAUA,CACZmB,MAAwB,EACsD;IAC9E,OAAOlB,YAAY,CAAC,IAAI,CAACe,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC1D;EAEA,MAAMjB,UAAUA,CACZiB,MAAwB,EACqC;IAC7D,OAAOhB,YAAY,CAAC,IAAI,CAACa,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC1D;EAEA,MAAMf,QAAQA,CACVe,MAAuB,EACsC;IAC7D,OAAOd,UAAU,CAAC,IAAI,CAACW,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACxD;EAEA,MAAMb,uBAAuBA,CACzBa,MAAqC,EAC6C;IAClF,OAAOZ,yBAAyB,CAAC,IAAI,CAACS,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACvE;EAEA,MAAMX,wBAAwBA,CAC1BW,MAAsC,EAC8C;IACpF,OAAOV,0BAA0B,CAAC,IAAI,CAACO,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACxE;EAEA,MAAMT,qBAAqBA,CACvBS,MAAmC,EAC0C;IAC7E,OAAOR,uBAAuB,CAAC,IAAI,CAACK,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACrE;EAEA,MAAMP,uBAAuBA,CACzBO,MAAqC,EACwB;IAC7D,OAAON,yBAAyB,CAAC,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACvE;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"FileManagerSdk.js","sources":["../src/FileManagerSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type {\n FmFile,\n FmTag,\n PresignedPostPayloadResponse\n} from \"./methods/fileManager/fileManagerTypes.js\";\nimport type { GetFileParams } from \"./methods/fileManager/getFile.js\";\nimport type { ListFilesParams, ListFilesResult } from \"./methods/fileManager/listFiles.js\";\nimport type { CreateFileParams } from \"./methods/fileManager/createFile.js\";\nimport type { CreateFilesParams, CreateFilesResult } from \"./methods/fileManager/createFiles.js\";\nimport type { UpdateFileParams } from \"./methods/fileManager/updateFile.js\";\nimport type { DeleteFileParams } from \"./methods/fileManager/deleteFile.js\";\nimport type { ListTagsParams } from \"./methods/fileManager/listTags.js\";\nimport type { GetPresignedPostPayloadParams } from \"./methods/fileManager/getPresignedPostPayload.js\";\nimport type { GetPresignedPostPayloadsParams } from \"./methods/fileManager/getPresignedPostPayloads.js\";\nimport type {\n CreateMultiPartUploadParams,\n MultiPartUploadResponse\n} from \"./methods/fileManager/createMultiPartUpload.js\";\nimport type { CompleteMultiPartUploadParams } from \"./methods/fileManager/completeMultiPartUpload.js\";\nimport type { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport { getFile as getFileFn } from \"./methods/fileManager/getFile.js\";\nimport { listFiles as listFilesFn } from \"./methods/fileManager/listFiles.js\";\nimport { createFile as createFileFn } from \"./methods/fileManager/createFile.js\";\nimport { createFiles as createFilesFn } from \"./methods/fileManager/createFiles.js\";\nimport { updateFile as updateFileFn } from \"./methods/fileManager/updateFile.js\";\nimport { deleteFile as deleteFileFn } from \"./methods/fileManager/deleteFile.js\";\nimport { listTags as listTagsFn } from \"./methods/fileManager/listTags.js\";\nimport { getPresignedPostPayload as getPresignedPostPayloadFn } from \"./methods/fileManager/getPresignedPostPayload.js\";\nimport { getPresignedPostPayloads as getPresignedPostPayloadsFn } from \"./methods/fileManager/getPresignedPostPayloads.js\";\nimport { createMultiPartUpload as createMultiPartUploadFn } from \"./methods/fileManager/createMultiPartUpload.js\";\nimport { completeMultiPartUpload as completeMultiPartUploadFn } from \"./methods/fileManager/completeMultiPartUpload.js\";\n\nexport class FileManagerSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async getFile(\n params: GetFileParams\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError | ValidationError>> {\n return getFileFn(this.config, this.fetchFn, params);\n }\n\n async listFiles(\n params: ListFilesParams\n ): Promise<Result<ListFilesResult, HttpError | ApiError | NetworkError | ValidationError>> {\n return listFilesFn(this.config, this.fetchFn, params);\n }\n\n async createFile(\n params: CreateFileParams\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError>> {\n return createFileFn(this.config, this.fetchFn, params);\n }\n\n async createFiles(\n params: CreateFilesParams\n ): Promise<Result<CreateFilesResult, HttpError | ApiError | NetworkError>> {\n return createFilesFn(this.config, this.fetchFn, params);\n }\n\n async updateFile(\n params: UpdateFileParams\n ): Promise<Result<FmFile, HttpError | ApiError | NetworkError | ValidationError>> {\n return updateFileFn(this.config, this.fetchFn, params);\n }\n\n async deleteFile(\n params: DeleteFileParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError>> {\n return deleteFileFn(this.config, this.fetchFn, params);\n }\n\n async listTags(\n params?: ListTagsParams\n ): Promise<Result<FmTag[], HttpError | ApiError | NetworkError>> {\n return listTagsFn(this.config, this.fetchFn, params);\n }\n\n async getPresignedPostPayload(\n params: GetPresignedPostPayloadParams\n ): Promise<Result<PresignedPostPayloadResponse, HttpError | ApiError | NetworkError>> {\n return getPresignedPostPayloadFn(this.config, this.fetchFn, params);\n }\n\n async getPresignedPostPayloads(\n params: GetPresignedPostPayloadsParams\n ): Promise<Result<PresignedPostPayloadResponse[], HttpError | ApiError | NetworkError>> {\n return getPresignedPostPayloadsFn(this.config, this.fetchFn, params);\n }\n\n async createMultiPartUpload(\n params: CreateMultiPartUploadParams\n ): Promise<Result<MultiPartUploadResponse, HttpError | ApiError | NetworkError>> {\n return createMultiPartUploadFn(this.config, this.fetchFn, params);\n }\n\n async completeMultiPartUpload(\n params: CompleteMultiPartUploadParams\n ): Promise<Result<boolean, HttpError | ApiError | NetworkError>> {\n return completeMultiPartUploadFn(this.config, this.fetchFn, params);\n }\n}\n"],"names":["FileManagerSdk","config","fetch","params","getFileFn","listFilesFn","createFileFn","createFilesFn","updateFileFn","deleteFileFn","listTagsFn","getPresignedPostPayloadFn","getPresignedPostPayloadsFn","createMultiPartUploadFn","completeMultiPartUploadFn"],"mappings":";;;;;;;;;;;AAkCO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,QACFC,MAAqB,EACyD;QAC9E,OAAOC,QAAU,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAED;IAChD;IAEA,MAAM,UACFA,MAAuB,EACgE;QACvF,OAAOE,UAAY,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEF;IAClD;IAEA,MAAM,WACFA,MAAwB,EACoC;QAC5D,OAAOG,WAAa,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEH;IACnD;IAEA,MAAM,YACFA,MAAyB,EAC8C;QACvE,OAAOI,YAAc,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEJ;IACpD;IAEA,MAAM,WACFA,MAAwB,EACsD;QAC9E,OAAOK,WAAa,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEL;IACnD;IAEA,MAAM,WACFA,MAAwB,EACqC;QAC7D,OAAOM,WAAa,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEN;IACnD;IAEA,MAAM,SACFA,MAAuB,EACsC;QAC7D,OAAOO,SAAW,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEP;IACjD;IAEA,MAAM,wBACFA,MAAqC,EAC6C;QAClF,OAAOQ,wBAA0B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAER;IAChE;IAEA,MAAM,yBACFA,MAAsC,EAC8C;QACpF,OAAOS,yBAA2B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAET;IACjE;IAEA,MAAM,sBACFA,MAAmC,EAC0C;QAC7E,OAAOU,sBAAwB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEV;IAC9D;IAEA,MAAM,wBACFA,MAAqC,EACwB;QAC7D,OAAOW,wBAA0B,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEX;IAChE;AACJ"}
package/LanguagesSdk.js CHANGED
@@ -1,12 +1,13 @@
1
- import { listLanguages as listLanguagesFn } from "./methods/languages/listLanguages.js";
2
- export class LanguagesSdk {
3
- constructor(config) {
4
- this.config = config;
5
- this.fetchFn = config.fetch || fetch;
6
- }
7
- async listLanguages() {
8
- return listLanguagesFn(this.config, this.fetchFn);
9
- }
1
+ import { listLanguages } from "./methods/languages/listLanguages.js";
2
+ class LanguagesSdk {
3
+ constructor(config){
4
+ this.config = config;
5
+ this.fetchFn = config.fetch || fetch;
6
+ }
7
+ async listLanguages() {
8
+ return listLanguages(this.config, this.fetchFn);
9
+ }
10
10
  }
11
+ export { LanguagesSdk };
11
12
 
12
13
  //# sourceMappingURL=LanguagesSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["listLanguages","listLanguagesFn","LanguagesSdk","constructor","config","fetchFn","fetch"],"sources":["LanguagesSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { HttpError, ApiError, NetworkError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport type { Language } from \"./methods/languages/listLanguages.js\";\nimport { listLanguages as listLanguagesFn } from \"./methods/languages/listLanguages.js\";\n\nexport class LanguagesSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async listLanguages(): Promise<Result<Language[], HttpError | ApiError | NetworkError>> {\n return listLanguagesFn(this.config, this.fetchFn);\n }\n}\n"],"mappings":"AAIA,SAASA,aAAa,IAAIC,eAAe;AAEzC,OAAO,MAAMC,YAAY,CAAC;EAItBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAMN,aAAaA,CAAA,EAAqE;IACpF,OAAOC,eAAe,CAAC,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,CAAC;EACrD;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"LanguagesSdk.js","sources":["../src/LanguagesSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { HttpError, ApiError, NetworkError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport type { Language } from \"./methods/languages/listLanguages.js\";\nimport { listLanguages as listLanguagesFn } from \"./methods/languages/listLanguages.js\";\n\nexport class LanguagesSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async listLanguages(): Promise<Result<Language[], HttpError | ApiError | NetworkError>> {\n return listLanguagesFn(this.config, this.fetchFn);\n }\n}\n"],"names":["LanguagesSdk","config","fetch","listLanguagesFn"],"mappings":";AAMO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,gBAAkF;QACpF,OAAOC,cAAgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO;IACpD;AACJ"}
package/Result.js CHANGED
@@ -1,143 +1,49 @@
1
- /**
2
- * A container type that represents either a successful result (`ok`) or a failure (`fail`).
3
- * Inspired by functional programming constructs like `Either` or `Result` in other languages.
4
- *
5
- * @template TValue - The type of the success value.
6
- * @template TError - The type of the error value.
7
- */
8
- export class Result {
9
- constructor(isOk, value, error) {
10
- this._isOk = isOk;
11
- this._value = value;
12
- this._error = error;
13
- }
14
-
15
- /**
16
- * Creates a successful `Result` containing the provided value.
17
- * If no value is provided, returns Result<void, never>.
18
- *
19
- * @param value - The value to wrap in a successful result (optional).
20
- * @returns A `Result` instance with the value.
21
- */
22
-
23
- static ok(value) {
24
- return new Result(true, value);
25
- }
26
-
27
- /**
28
- * Creates a failed `Result` containing the provided error.
29
- *
30
- * @param error - The error to wrap in a failed result.
31
- * @returns A `Result` instance with the error.
32
- */
33
- static fail(error) {
34
- return new Result(false, undefined, error);
35
- }
36
-
37
- /**
38
- * Checks whether the result is successful.
39
- *
40
- * @returns `true` if the result is `ok`, otherwise `false`.
41
- * Acts as a type guard to narrow the type to a successful result.
42
- */
43
- isOk() {
44
- return this._isOk;
45
- }
46
-
47
- /**
48
- * Checks whether the result is a failure.
49
- *
50
- * @returns `true` if the result is `fail`, otherwise `false`.
51
- * Acts as a type guard to narrow the type to a failed result.
52
- */
53
- isFail() {
54
- return !this._isOk;
55
- }
56
-
57
- /**
58
- * Gets the value inside a successful result.
59
- *
60
- * @throws If the result is a failure.
61
- * @returns The success value.
62
- */
63
- get value() {
64
- if (!this._isOk) {
65
- console.error(this.error);
66
- throw new Error("Tried to get value from a failed Result.");
1
+ class Result {
2
+ constructor(isOk, value, error){
3
+ this._isOk = isOk;
4
+ this._value = value;
5
+ this._error = error;
67
6
  }
68
- return this._value;
69
- }
70
-
71
- /**
72
- * Gets the error inside a failed result.
73
- *
74
- * @throws If the result is successful.
75
- * @returns The error value.
76
- */
77
- get error() {
78
- if (this._isOk) {
79
- throw new Error("Tried to get error from a successful Result.");
7
+ static ok(value) {
8
+ return new Result(true, value);
80
9
  }
81
- return this._error;
82
- }
83
-
84
- /**
85
- * Transforms the success value using the provided mapping function.
86
- *
87
- * @template U - The type of the new success value.
88
- * @param fn - Function to apply to the value if the result is successful.
89
- * @returns A new `Result` containing the mapped value, or the original error if failed.
90
- */
91
- map(fn) {
92
- if (this.isOk()) {
93
- return Result.ok(fn(this._value));
10
+ static fail(error) {
11
+ return new Result(false, void 0, error);
94
12
  }
95
- return Result.fail(this._error);
96
- }
97
-
98
- /**
99
- * Transforms the error value using the provided mapping function.
100
- *
101
- * @template F - The type of the new error.
102
- * @param fn - Function to apply to the error if the result is a failure.
103
- * @returns A new `Result` containing the original value or the mapped error.
104
- */
105
- mapError(fn) {
106
- if (this.isFail()) {
107
- return Result.fail(fn(this._error));
13
+ isOk() {
14
+ return this._isOk;
108
15
  }
109
- return Result.ok(this._value);
110
- }
111
-
112
- /**
113
- * Chains another `Result`-producing function onto this result.
114
- * If this result is successful, the function is applied to the value.
115
- * If this result is a failure, the original error is returned.
116
- *
117
- * @template U - The type of the next success value.
118
- * @param fn - A function that takes the current value and returns another `Result`.
119
- * @returns A new `Result` from applying the function or the original failure.
120
- */
121
- flatMap(fn) {
122
- if (this.isOk()) {
123
- return fn(this._value);
16
+ isFail() {
17
+ return !this._isOk;
124
18
  }
125
- return Result.fail(this._error);
126
- }
127
-
128
- /**
129
- * Pattern-matches the result to handle both success and failure cases.
130
- *
131
- * @template U - The return type of both match functions.
132
- * @param handlers - An object containing `ok` and `fail` handlers.
133
- * @returns The return value from the corresponding handler.
134
- */
135
- match(handlers) {
136
- if (this.isOk()) {
137
- return handlers.ok(this._value);
19
+ get value() {
20
+ if (!this._isOk) {
21
+ console.error(this.error);
22
+ throw new Error("Tried to get value from a failed Result.");
23
+ }
24
+ return this._value;
25
+ }
26
+ get error() {
27
+ if (this._isOk) throw new Error("Tried to get error from a successful Result.");
28
+ return this._error;
29
+ }
30
+ map(fn) {
31
+ if (this.isOk()) return Result.ok(fn(this._value));
32
+ return Result.fail(this._error);
33
+ }
34
+ mapError(fn) {
35
+ if (this.isFail()) return Result.fail(fn(this._error));
36
+ return Result.ok(this._value);
37
+ }
38
+ flatMap(fn) {
39
+ if (this.isOk()) return fn(this._value);
40
+ return Result.fail(this._error);
41
+ }
42
+ match(handlers) {
43
+ if (this.isOk()) return handlers.ok(this._value);
44
+ return handlers.fail(this._error);
138
45
  }
139
- return handlers.fail(this._error);
140
- }
141
46
  }
47
+ export { Result };
142
48
 
143
49
  //# sourceMappingURL=Result.js.map
package/Result.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Result","constructor","isOk","value","error","_isOk","_value","_error","ok","fail","undefined","isFail","console","Error","map","fn","mapError","flatMap","match","handlers"],"sources":["Result.ts"],"sourcesContent":["/**\n * A container type that represents either a successful result (`ok`) or a failure (`fail`).\n * Inspired by functional programming constructs like `Either` or `Result` in other languages.\n *\n * @template TValue - The type of the success value.\n * @template TError - The type of the error value.\n */\nexport class Result<TValue, TError = never> {\n protected readonly _isOk: boolean;\n protected readonly _value?: TValue;\n protected readonly _error?: TError;\n\n private constructor(isOk: boolean, value?: TValue, error?: TError) {\n this._isOk = isOk;\n this._value = value;\n this._error = error;\n }\n\n /**\n * Creates a successful `Result` containing the provided value.\n * If no value is provided, returns Result<void, never>.\n *\n * @param value - The value to wrap in a successful result (optional).\n * @returns A `Result` instance with the value.\n */\n public static ok<T>(value: T): Result<T, never>;\n public static ok(): Result<void, never>;\n public static ok<T>(value?: T): Result<T | void, never> {\n return new Result<T | void, never>(true, value);\n }\n\n /**\n * Creates a failed `Result` containing the provided error.\n *\n * @param error - The error to wrap in a failed result.\n * @returns A `Result` instance with the error.\n */\n public static fail<E>(error: E): Result<never, E> {\n return new Result<never, E>(false, undefined, error);\n }\n\n /**\n * Checks whether the result is successful.\n *\n * @returns `true` if the result is `ok`, otherwise `false`.\n * Acts as a type guard to narrow the type to a successful result.\n */\n public isOk(): this is { _value: TValue } & Result<TValue, TError> {\n return this._isOk;\n }\n\n /**\n * Checks whether the result is a failure.\n *\n * @returns `true` if the result is `fail`, otherwise `false`.\n * Acts as a type guard to narrow the type to a failed result.\n */\n public isFail(): this is { _error: TError } & Result<TValue, TError> {\n return !this._isOk;\n }\n\n /**\n * Gets the value inside a successful result.\n *\n * @throws If the result is a failure.\n * @returns The success value.\n */\n public get value(): TValue {\n if (!this._isOk) {\n console.error(this.error);\n throw new Error(\"Tried to get value from a failed Result.\");\n }\n\n return this._value as TValue;\n }\n\n /**\n * Gets the error inside a failed result.\n *\n * @throws If the result is successful.\n * @returns The error value.\n */\n public get error(): TError {\n if (this._isOk) {\n throw new Error(\"Tried to get error from a successful Result.\");\n }\n\n return this._error as TError;\n }\n\n /**\n * Transforms the success value using the provided mapping function.\n *\n * @template U - The type of the new success value.\n * @param fn - Function to apply to the value if the result is successful.\n * @returns A new `Result` containing the mapped value, or the original error if failed.\n */\n public map<U>(fn: (value: TValue) => U): Result<U, TError> {\n if (this.isOk()) {\n return Result.ok(fn(this._value as TValue));\n }\n\n return Result.fail(this._error as TError);\n }\n\n /**\n * Transforms the error value using the provided mapping function.\n *\n * @template F - The type of the new error.\n * @param fn - Function to apply to the error if the result is a failure.\n * @returns A new `Result` containing the original value or the mapped error.\n */\n public mapError<F>(fn: (error: TError) => F): Result<TValue, F> {\n if (this.isFail()) {\n return Result.fail(fn(this._error as TError));\n }\n\n return Result.ok(this._value as TValue);\n }\n\n /**\n * Chains another `Result`-producing function onto this result.\n * If this result is successful, the function is applied to the value.\n * If this result is a failure, the original error is returned.\n *\n * @template U - The type of the next success value.\n * @param fn - A function that takes the current value and returns another `Result`.\n * @returns A new `Result` from applying the function or the original failure.\n */\n public flatMap<U>(fn: (value: TValue) => Result<U, TError>): Result<U, TError> {\n if (this.isOk()) {\n return fn(this._value as TValue);\n }\n\n return Result.fail(this._error as TError);\n }\n\n /**\n * Pattern-matches the result to handle both success and failure cases.\n *\n * @template U - The return type of both match functions.\n * @param handlers - An object containing `ok` and `fail` handlers.\n * @returns The return value from the corresponding handler.\n */\n public match<U>(handlers: { ok: (value: TValue) => U; fail: (error: TError) => U }): U {\n if (this.isOk()) {\n return handlers.ok(this._value as TValue);\n }\n\n return handlers.fail(this._error as TError);\n }\n}\n\nexport namespace Result {\n export type UnwrapResult<T> = Awaited<T> extends Result<infer Ok, any> ? Ok : never;\n export type UnwrapError<T> = Awaited<T> extends Result<any, infer Err> ? Err : never;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,MAAM,CAAyB;EAKhCC,WAAWA,CAACC,IAAa,EAAEC,KAAc,EAAEC,KAAc,EAAE;IAC/D,IAAI,CAACC,KAAK,GAAGH,IAAI;IACjB,IAAI,CAACI,MAAM,GAAGH,KAAK;IACnB,IAAI,CAACI,MAAM,GAAGH,KAAK;EACvB;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;;EAGI,OAAcI,EAAEA,CAAIL,KAAS,EAA2B;IACpD,OAAO,IAAIH,MAAM,CAAkB,IAAI,EAAEG,KAAK,CAAC;EACnD;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,OAAcM,IAAIA,CAAIL,KAAQ,EAAoB;IAC9C,OAAO,IAAIJ,MAAM,CAAW,KAAK,EAAEU,SAAS,EAAEN,KAAK,CAAC;EACxD;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACWF,IAAIA,CAAA,EAAwD;IAC/D,OAAO,IAAI,CAACG,KAAK;EACrB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACWM,MAAMA,CAAA,EAAwD;IACjE,OAAO,CAAC,IAAI,CAACN,KAAK;EACtB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,IAAWF,KAAKA,CAAA,EAAW;IACvB,IAAI,CAAC,IAAI,CAACE,KAAK,EAAE;MACbO,OAAO,CAACR,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;MACzB,MAAM,IAAIS,KAAK,CAAC,0CAA0C,CAAC;IAC/D;IAEA,OAAO,IAAI,CAACP,MAAM;EACtB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,IAAWF,KAAKA,CAAA,EAAW;IACvB,IAAI,IAAI,CAACC,KAAK,EAAE;MACZ,MAAM,IAAIQ,KAAK,CAAC,8CAA8C,CAAC;IACnE;IAEA,OAAO,IAAI,CAACN,MAAM;EACtB;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACWO,GAAGA,CAAIC,EAAwB,EAAqB;IACvD,IAAI,IAAI,CAACb,IAAI,CAAC,CAAC,EAAE;MACb,OAAOF,MAAM,CAACQ,EAAE,CAACO,EAAE,CAAC,IAAI,CAACT,MAAgB,CAAC,CAAC;IAC/C;IAEA,OAAON,MAAM,CAACS,IAAI,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC7C;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACWS,QAAQA,CAAID,EAAwB,EAAqB;IAC5D,IAAI,IAAI,CAACJ,MAAM,CAAC,CAAC,EAAE;MACf,OAAOX,MAAM,CAACS,IAAI,CAACM,EAAE,CAAC,IAAI,CAACR,MAAgB,CAAC,CAAC;IACjD;IAEA,OAAOP,MAAM,CAACQ,EAAE,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC3C;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACWW,OAAOA,CAAIF,EAAwC,EAAqB;IAC3E,IAAI,IAAI,CAACb,IAAI,CAAC,CAAC,EAAE;MACb,OAAOa,EAAE,CAAC,IAAI,CAACT,MAAgB,CAAC;IACpC;IAEA,OAAON,MAAM,CAACS,IAAI,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC7C;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACWW,KAAKA,CAAIC,QAAkE,EAAK;IACnF,IAAI,IAAI,CAACjB,IAAI,CAAC,CAAC,EAAE;MACb,OAAOiB,QAAQ,CAACX,EAAE,CAAC,IAAI,CAACF,MAAgB,CAAC;IAC7C;IAEA,OAAOa,QAAQ,CAACV,IAAI,CAAC,IAAI,CAACF,MAAgB,CAAC;EAC/C;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"Result.js","sources":["../src/Result.ts"],"sourcesContent":["/**\n * A container type that represents either a successful result (`ok`) or a failure (`fail`).\n * Inspired by functional programming constructs like `Either` or `Result` in other languages.\n *\n * @template TValue - The type of the success value.\n * @template TError - The type of the error value.\n */\nexport class Result<TValue, TError = never> {\n protected readonly _isOk: boolean;\n protected readonly _value?: TValue;\n protected readonly _error?: TError;\n\n private constructor(isOk: boolean, value?: TValue, error?: TError) {\n this._isOk = isOk;\n this._value = value;\n this._error = error;\n }\n\n /**\n * Creates a successful `Result` containing the provided value.\n * If no value is provided, returns Result<void, never>.\n *\n * @param value - The value to wrap in a successful result (optional).\n * @returns A `Result` instance with the value.\n */\n public static ok<T>(value: T): Result<T, never>;\n public static ok(): Result<void, never>;\n public static ok<T>(value?: T): Result<T | void, never> {\n return new Result<T | void, never>(true, value);\n }\n\n /**\n * Creates a failed `Result` containing the provided error.\n *\n * @param error - The error to wrap in a failed result.\n * @returns A `Result` instance with the error.\n */\n public static fail<E>(error: E): Result<never, E> {\n return new Result<never, E>(false, undefined, error);\n }\n\n /**\n * Checks whether the result is successful.\n *\n * @returns `true` if the result is `ok`, otherwise `false`.\n * Acts as a type guard to narrow the type to a successful result.\n */\n public isOk(): this is { _value: TValue } & Result<TValue, TError> {\n return this._isOk;\n }\n\n /**\n * Checks whether the result is a failure.\n *\n * @returns `true` if the result is `fail`, otherwise `false`.\n * Acts as a type guard to narrow the type to a failed result.\n */\n public isFail(): this is { _error: TError } & Result<TValue, TError> {\n return !this._isOk;\n }\n\n /**\n * Gets the value inside a successful result.\n *\n * @throws If the result is a failure.\n * @returns The success value.\n */\n public get value(): TValue {\n if (!this._isOk) {\n console.error(this.error);\n throw new Error(\"Tried to get value from a failed Result.\");\n }\n\n return this._value as TValue;\n }\n\n /**\n * Gets the error inside a failed result.\n *\n * @throws If the result is successful.\n * @returns The error value.\n */\n public get error(): TError {\n if (this._isOk) {\n throw new Error(\"Tried to get error from a successful Result.\");\n }\n\n return this._error as TError;\n }\n\n /**\n * Transforms the success value using the provided mapping function.\n *\n * @template U - The type of the new success value.\n * @param fn - Function to apply to the value if the result is successful.\n * @returns A new `Result` containing the mapped value, or the original error if failed.\n */\n public map<U>(fn: (value: TValue) => U): Result<U, TError> {\n if (this.isOk()) {\n return Result.ok(fn(this._value as TValue));\n }\n\n return Result.fail(this._error as TError);\n }\n\n /**\n * Transforms the error value using the provided mapping function.\n *\n * @template F - The type of the new error.\n * @param fn - Function to apply to the error if the result is a failure.\n * @returns A new `Result` containing the original value or the mapped error.\n */\n public mapError<F>(fn: (error: TError) => F): Result<TValue, F> {\n if (this.isFail()) {\n return Result.fail(fn(this._error as TError));\n }\n\n return Result.ok(this._value as TValue);\n }\n\n /**\n * Chains another `Result`-producing function onto this result.\n * If this result is successful, the function is applied to the value.\n * If this result is a failure, the original error is returned.\n *\n * @template U - The type of the next success value.\n * @param fn - A function that takes the current value and returns another `Result`.\n * @returns A new `Result` from applying the function or the original failure.\n */\n public flatMap<U>(fn: (value: TValue) => Result<U, TError>): Result<U, TError> {\n if (this.isOk()) {\n return fn(this._value as TValue);\n }\n\n return Result.fail(this._error as TError);\n }\n\n /**\n * Pattern-matches the result to handle both success and failure cases.\n *\n * @template U - The return type of both match functions.\n * @param handlers - An object containing `ok` and `fail` handlers.\n * @returns The return value from the corresponding handler.\n */\n public match<U>(handlers: { ok: (value: TValue) => U; fail: (error: TError) => U }): U {\n if (this.isOk()) {\n return handlers.ok(this._value as TValue);\n }\n\n return handlers.fail(this._error as TError);\n }\n}\n\nexport namespace Result {\n export type UnwrapResult<T> = Awaited<T> extends Result<infer Ok, any> ? Ok : never;\n export type UnwrapError<T> = Awaited<T> extends Result<any, infer Err> ? Err : never;\n}\n"],"names":["Result","isOk","value","error","undefined","console","Error","fn","handlers"],"mappings":"AAOO,MAAMA;IAKT,YAAoBC,IAAa,EAAEC,KAAc,EAAEC,KAAc,CAAE;QAC/D,IAAI,CAAC,KAAK,GAAGF;QACb,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,MAAM,GAAGC;IAClB;IAWA,OAAc,GAAMD,KAAS,EAA2B;QACpD,OAAO,IAAIF,OAAwB,MAAME;IAC7C;IAQA,OAAc,KAAQC,KAAQ,EAAoB;QAC9C,OAAO,IAAIH,OAAiB,OAAOI,QAAWD;IAClD;IAQO,OAA4D;QAC/D,OAAO,IAAI,CAAC,KAAK;IACrB;IAQO,SAA8D;QACjE,OAAO,CAAC,IAAI,CAAC,KAAK;IACtB;IAQA,IAAW,QAAgB;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACbE,QAAQ,KAAK,CAAC,IAAI,CAAC,KAAK;YACxB,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAO,IAAI,CAAC,MAAM;IACtB;IAQA,IAAW,QAAgB;QACvB,IAAI,IAAI,CAAC,KAAK,EACV,MAAM,IAAIA,MAAM;QAGpB,OAAO,IAAI,CAAC,MAAM;IACtB;IASO,IAAOC,EAAwB,EAAqB;QACvD,IAAI,IAAI,CAAC,IAAI,IACT,OAAOP,OAAO,EAAE,CAACO,GAAG,IAAI,CAAC,MAAM;QAGnC,OAAOP,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM;IAClC;IASO,SAAYO,EAAwB,EAAqB;QAC5D,IAAI,IAAI,CAAC,MAAM,IACX,OAAOP,OAAO,IAAI,CAACO,GAAG,IAAI,CAAC,MAAM;QAGrC,OAAOP,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM;IAChC;IAWO,QAAWO,EAAwC,EAAqB;QAC3E,IAAI,IAAI,CAAC,IAAI,IACT,OAAOA,GAAG,IAAI,CAAC,MAAM;QAGzB,OAAOP,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM;IAClC;IASO,MAASQ,QAAkE,EAAK;QACnF,IAAI,IAAI,CAAC,IAAI,IACT,OAAOA,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM;QAGlC,OAAOA,SAAS,IAAI,CAAC,IAAI,CAAC,MAAM;IACpC;AACJ"}
package/TasksSdk.js CHANGED
@@ -1,28 +1,29 @@
1
- import { listDefinitions as listDefinitionsFn } from "./methods/tasks/listDefinitions.js";
2
- import { listTasks as listTasksFn } from "./methods/tasks/listTasks.js";
3
- import { listLogs as listLogsFn } from "./methods/tasks/listLogs.js";
4
- import { triggerTask as triggerTaskFn } from "./methods/tasks/triggerTask.js";
5
- import { abortTask as abortTaskFn } from "./methods/tasks/abortTask.js";
6
- export class TasksSdk {
7
- constructor(config) {
8
- this.config = config;
9
- this.fetchFn = config.fetch || fetch;
10
- }
11
- async listDefinitions() {
12
- return listDefinitionsFn(this.config, this.fetchFn);
13
- }
14
- async listTasks() {
15
- return listTasksFn(this.config, this.fetchFn);
16
- }
17
- async listLogs(params) {
18
- return listLogsFn(this.config, this.fetchFn, params ?? {});
19
- }
20
- async triggerTask(params) {
21
- return triggerTaskFn(this.config, this.fetchFn, params);
22
- }
23
- async abortTask(params) {
24
- return abortTaskFn(this.config, this.fetchFn, params);
25
- }
1
+ import { listDefinitions } from "./methods/tasks/listDefinitions.js";
2
+ import { listTasks } from "./methods/tasks/listTasks.js";
3
+ import { listLogs } from "./methods/tasks/listLogs.js";
4
+ import { triggerTask } from "./methods/tasks/triggerTask.js";
5
+ import { abortTask } from "./methods/tasks/abortTask.js";
6
+ class TasksSdk {
7
+ constructor(config){
8
+ this.config = config;
9
+ this.fetchFn = config.fetch || fetch;
10
+ }
11
+ async listDefinitions() {
12
+ return listDefinitions(this.config, this.fetchFn);
13
+ }
14
+ async listTasks() {
15
+ return listTasks(this.config, this.fetchFn);
16
+ }
17
+ async listLogs(params) {
18
+ return listLogs(this.config, this.fetchFn, params ?? {});
19
+ }
20
+ async triggerTask(params) {
21
+ return triggerTask(this.config, this.fetchFn, params);
22
+ }
23
+ async abortTask(params) {
24
+ return abortTask(this.config, this.fetchFn, params);
25
+ }
26
26
  }
27
+ export { TasksSdk };
27
28
 
28
29
  //# sourceMappingURL=TasksSdk.js.map
package/TasksSdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["listDefinitions","listDefinitionsFn","listTasks","listTasksFn","listLogs","listLogsFn","triggerTask","triggerTaskFn","abortTask","abortTaskFn","TasksSdk","constructor","config","fetchFn","fetch","params"],"sources":["TasksSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport type { TaskDefinition, TaskRun, TaskLog } from \"./methods/tasks/taskTypes.js\";\nimport type { ListLogsParams } from \"./methods/tasks/listLogs.js\";\nimport type { TriggerTaskParams } from \"./methods/tasks/triggerTask.js\";\nimport type { AbortTaskParams } from \"./methods/tasks/abortTask.js\";\nimport { listDefinitions as listDefinitionsFn } from \"./methods/tasks/listDefinitions.js\";\nimport { listTasks as listTasksFn } from \"./methods/tasks/listTasks.js\";\nimport { listLogs as listLogsFn } from \"./methods/tasks/listLogs.js\";\nimport { triggerTask as triggerTaskFn } from \"./methods/tasks/triggerTask.js\";\nimport { abortTask as abortTaskFn } from \"./methods/tasks/abortTask.js\";\n\nexport class TasksSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async listDefinitions(): Promise<\n Result<TaskDefinition[], HttpError | ApiError | NetworkError>\n > {\n return listDefinitionsFn(this.config, this.fetchFn);\n }\n\n async listTasks(): Promise<Result<TaskRun[], HttpError | ApiError | NetworkError>> {\n return listTasksFn(this.config, this.fetchFn);\n }\n\n async listLogs(\n params?: ListLogsParams\n ): Promise<Result<TaskLog[], HttpError | ApiError | NetworkError | ValidationError>> {\n return listLogsFn(this.config, this.fetchFn, params ?? {});\n }\n\n async triggerTask(\n params: TriggerTaskParams\n ): Promise<Result<TaskRun, HttpError | ApiError | NetworkError | ValidationError>> {\n return triggerTaskFn(this.config, this.fetchFn, params);\n }\n\n async abortTask(\n params: AbortTaskParams\n ): Promise<Result<TaskRun, HttpError | ApiError | NetworkError | ValidationError>> {\n return abortTaskFn(this.config, this.fetchFn, params);\n }\n}\n"],"mappings":"AAOA,SAASA,eAAe,IAAIC,iBAAiB;AAC7C,SAASC,SAAS,IAAIC,WAAW;AACjC,SAASC,QAAQ,IAAIC,UAAU;AAC/B,SAASC,WAAW,IAAIC,aAAa;AACrC,SAASC,SAAS,IAAIC,WAAW;AAEjC,OAAO,MAAMC,QAAQ,CAAC;EAIlBC,WAAWA,CAACC,MAAoB,EAAE;IAC9B,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACE,KAAK,IAAIA,KAAK;EACxC;EAEA,MAAMd,eAAeA,CAAA,EAEnB;IACE,OAAOC,iBAAiB,CAAC,IAAI,CAACW,MAAM,EAAE,IAAI,CAACC,OAAO,CAAC;EACvD;EAEA,MAAMX,SAASA,CAAA,EAAoE;IAC/E,OAAOC,WAAW,CAAC,IAAI,CAACS,MAAM,EAAE,IAAI,CAACC,OAAO,CAAC;EACjD;EAEA,MAAMT,QAAQA,CACVW,MAAuB,EAC0D;IACjF,OAAOV,UAAU,CAAC,IAAI,CAACO,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,IAAI,CAAC,CAAC,CAAC;EAC9D;EAEA,MAAMT,WAAWA,CACbS,MAAyB,EACsD;IAC/E,OAAOR,aAAa,CAAC,IAAI,CAACK,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EAC3D;EAEA,MAAMP,SAASA,CACXO,MAAuB,EACwD;IAC/E,OAAON,WAAW,CAAC,IAAI,CAACG,MAAM,EAAE,IAAI,CAACC,OAAO,EAAEE,MAAM,CAAC;EACzD;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"TasksSdk.js","sources":["../src/TasksSdk.ts"],"sourcesContent":["import type { WebinyConfig } from \"./types.js\";\nimport type { HttpError, ApiError, NetworkError, ValidationError } from \"./errors.js\";\nimport type { Result } from \"./Result.js\";\nimport type { TaskDefinition, TaskRun, TaskLog } from \"./methods/tasks/taskTypes.js\";\nimport type { ListLogsParams } from \"./methods/tasks/listLogs.js\";\nimport type { TriggerTaskParams } from \"./methods/tasks/triggerTask.js\";\nimport type { AbortTaskParams } from \"./methods/tasks/abortTask.js\";\nimport { listDefinitions as listDefinitionsFn } from \"./methods/tasks/listDefinitions.js\";\nimport { listTasks as listTasksFn } from \"./methods/tasks/listTasks.js\";\nimport { listLogs as listLogsFn } from \"./methods/tasks/listLogs.js\";\nimport { triggerTask as triggerTaskFn } from \"./methods/tasks/triggerTask.js\";\nimport { abortTask as abortTaskFn } from \"./methods/tasks/abortTask.js\";\n\nexport class TasksSdk {\n private config: WebinyConfig;\n private fetchFn: typeof fetch;\n\n constructor(config: WebinyConfig) {\n this.config = config;\n this.fetchFn = config.fetch || fetch;\n }\n\n async listDefinitions(): Promise<\n Result<TaskDefinition[], HttpError | ApiError | NetworkError>\n > {\n return listDefinitionsFn(this.config, this.fetchFn);\n }\n\n async listTasks(): Promise<Result<TaskRun[], HttpError | ApiError | NetworkError>> {\n return listTasksFn(this.config, this.fetchFn);\n }\n\n async listLogs(\n params?: ListLogsParams\n ): Promise<Result<TaskLog[], HttpError | ApiError | NetworkError | ValidationError>> {\n return listLogsFn(this.config, this.fetchFn, params ?? {});\n }\n\n async triggerTask(\n params: TriggerTaskParams\n ): Promise<Result<TaskRun, HttpError | ApiError | NetworkError | ValidationError>> {\n return triggerTaskFn(this.config, this.fetchFn, params);\n }\n\n async abortTask(\n params: AbortTaskParams\n ): Promise<Result<TaskRun, HttpError | ApiError | NetworkError | ValidationError>> {\n return abortTaskFn(this.config, this.fetchFn, params);\n }\n}\n"],"names":["TasksSdk","config","fetch","listDefinitionsFn","listTasksFn","params","listLogsFn","triggerTaskFn","abortTaskFn"],"mappings":";;;;;AAaO,MAAMA;IAIT,YAAYC,MAAoB,CAAE;QAC9B,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,OAAO,GAAGA,OAAO,KAAK,IAAIC;IACnC;IAEA,MAAM,kBAEJ;QACE,OAAOC,gBAAkB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO;IACtD;IAEA,MAAM,YAA6E;QAC/E,OAAOC,UAAY,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO;IAChD;IAEA,MAAM,SACFC,MAAuB,EAC0D;QACjF,OAAOC,SAAW,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAED,UAAU,CAAC;IAC5D;IAEA,MAAM,YACFA,MAAyB,EACsD;QAC/E,OAAOE,YAAc,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEF;IACpD;IAEA,MAAM,UACFA,MAAuB,EACwD;QAC/E,OAAOG,UAAY,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAEH;IAClD;AACJ"}