@aws-amplify/api-graphql 4.0.29-unstable.f37faeb.0 → 4.0.29

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 (129) hide show
  1. package/dist/cjs/internals/generateClient.js +4 -14
  2. package/dist/cjs/internals/generateClient.js.map +1 -1
  3. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +3 -8
  4. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
  5. package/dist/cjs/internals/v6.js +6 -3
  6. package/dist/cjs/internals/v6.js.map +1 -1
  7. package/dist/cjs/types/index.js +11 -1
  8. package/dist/cjs/types/index.js.map +1 -1
  9. package/dist/cjs/utils/index.js +1 -5
  10. package/dist/cjs/utils/index.js.map +1 -1
  11. package/dist/esm/GraphQLAPI.d.ts +1 -1
  12. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  13. package/dist/esm/index.mjs +1 -1
  14. package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
  15. package/dist/esm/internals/generateClient.mjs +5 -15
  16. package/dist/esm/internals/generateClient.mjs.map +1 -1
  17. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +4 -9
  18. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
  19. package/dist/esm/internals/types.d.ts +1 -1
  20. package/dist/esm/internals/v6.d.ts +1 -1
  21. package/dist/esm/internals/v6.mjs +7 -4
  22. package/dist/esm/internals/v6.mjs.map +1 -1
  23. package/dist/esm/types/index.d.ts +10 -40
  24. package/dist/esm/types/index.mjs +10 -1
  25. package/dist/esm/types/index.mjs.map +1 -1
  26. package/dist/esm/utils/index.d.ts +0 -2
  27. package/dist/esm/utils/index.mjs +0 -2
  28. package/dist/esm/utils/index.mjs.map +1 -1
  29. package/package.json +5 -6
  30. package/src/GraphQLAPI.ts +1 -1
  31. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +4 -1
  32. package/src/internals/InternalGraphQLAPI.ts +4 -1
  33. package/src/internals/generateClient.ts +8 -36
  34. package/src/internals/server/generateClientWithAmplifyInstance.ts +6 -16
  35. package/src/internals/types.ts +1 -1
  36. package/src/internals/v6.ts +7 -7
  37. package/src/server/generateClient.ts +1 -1
  38. package/src/types/index.ts +36 -60
  39. package/src/utils/index.ts +0 -2
  40. package/dist/cjs/internals/APIClient.js +0 -733
  41. package/dist/cjs/internals/APIClient.js.map +0 -1
  42. package/dist/cjs/internals/clientUtils.js +0 -29
  43. package/dist/cjs/internals/clientUtils.js.map +0 -1
  44. package/dist/cjs/internals/generateCustomOperationsProperty.js +0 -50
  45. package/dist/cjs/internals/generateCustomOperationsProperty.js.map +0 -1
  46. package/dist/cjs/internals/operations/custom.js +0 -356
  47. package/dist/cjs/internals/operations/custom.js.map +0 -1
  48. package/dist/cjs/internals/operations/get.js +0 -62
  49. package/dist/cjs/internals/operations/get.js.map +0 -1
  50. package/dist/cjs/internals/operations/indexQuery.js +0 -75
  51. package/dist/cjs/internals/operations/indexQuery.js.map +0 -1
  52. package/dist/cjs/internals/operations/list.js +0 -74
  53. package/dist/cjs/internals/operations/list.js.map +0 -1
  54. package/dist/cjs/internals/operations/observeQuery.js +0 -121
  55. package/dist/cjs/internals/operations/observeQuery.js.map +0 -1
  56. package/dist/cjs/internals/operations/subscription.js +0 -31
  57. package/dist/cjs/internals/operations/subscription.js.map +0 -1
  58. package/dist/cjs/internals/server/generateModelsProperty.js +0 -53
  59. package/dist/cjs/internals/server/generateModelsProperty.js.map +0 -1
  60. package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js +0 -21
  61. package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js.map +0 -1
  62. package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js +0 -45
  63. package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js.map +0 -1
  64. package/dist/cjs/utils/findIndexByFields.js +0 -25
  65. package/dist/cjs/utils/findIndexByFields.js.map +0 -1
  66. package/dist/cjs/utils/resolveOwnerFields.js +0 -48
  67. package/dist/cjs/utils/resolveOwnerFields.js.map +0 -1
  68. package/dist/cjs/utils/resolvePKFields.js +0 -17
  69. package/dist/cjs/utils/resolvePKFields.js.map +0 -1
  70. package/dist/esm/internals/APIClient.d.ts +0 -126
  71. package/dist/esm/internals/APIClient.mjs +0 -721
  72. package/dist/esm/internals/APIClient.mjs.map +0 -1
  73. package/dist/esm/internals/clientUtils.d.ts +0 -6
  74. package/dist/esm/internals/clientUtils.mjs +0 -26
  75. package/dist/esm/internals/clientUtils.mjs.map +0 -1
  76. package/dist/esm/internals/generateCustomOperationsProperty.d.ts +0 -9
  77. package/dist/esm/internals/generateCustomOperationsProperty.mjs +0 -45
  78. package/dist/esm/internals/generateCustomOperationsProperty.mjs.map +0 -1
  79. package/dist/esm/internals/operations/custom.d.ts +0 -63
  80. package/dist/esm/internals/operations/custom.mjs +0 -354
  81. package/dist/esm/internals/operations/custom.mjs.map +0 -1
  82. package/dist/esm/internals/operations/get.d.ts +0 -5
  83. package/dist/esm/internals/operations/get.mjs +0 -60
  84. package/dist/esm/internals/operations/get.mjs.map +0 -1
  85. package/dist/esm/internals/operations/indexQuery.d.ts +0 -9
  86. package/dist/esm/internals/operations/indexQuery.mjs +0 -73
  87. package/dist/esm/internals/operations/indexQuery.mjs.map +0 -1
  88. package/dist/esm/internals/operations/list.d.ts +0 -4
  89. package/dist/esm/internals/operations/list.mjs +0 -72
  90. package/dist/esm/internals/operations/list.mjs.map +0 -1
  91. package/dist/esm/internals/operations/observeQuery.d.ts +0 -3
  92. package/dist/esm/internals/operations/observeQuery.mjs +0 -121
  93. package/dist/esm/internals/operations/observeQuery.mjs.map +0 -1
  94. package/dist/esm/internals/operations/subscription.d.ts +0 -3
  95. package/dist/esm/internals/operations/subscription.mjs +0 -29
  96. package/dist/esm/internals/operations/subscription.mjs.map +0 -1
  97. package/dist/esm/internals/server/generateModelsProperty.d.ts +0 -3
  98. package/dist/esm/internals/server/generateModelsProperty.mjs +0 -51
  99. package/dist/esm/internals/server/generateModelsProperty.mjs.map +0 -1
  100. package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.d.ts +0 -3
  101. package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs +0 -18
  102. package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs.map +0 -1
  103. package/dist/esm/internals/utils/clientProperties/generateModelsProperty.d.ts +0 -4
  104. package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs +0 -43
  105. package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs.map +0 -1
  106. package/dist/esm/utils/findIndexByFields.d.ts +0 -9
  107. package/dist/esm/utils/findIndexByFields.mjs +0 -22
  108. package/dist/esm/utils/findIndexByFields.mjs.map +0 -1
  109. package/dist/esm/utils/resolveOwnerFields.d.ts +0 -12
  110. package/dist/esm/utils/resolveOwnerFields.mjs +0 -45
  111. package/dist/esm/utils/resolveOwnerFields.mjs.map +0 -1
  112. package/dist/esm/utils/resolvePKFields.d.ts +0 -13
  113. package/dist/esm/utils/resolvePKFields.mjs +0 -14
  114. package/dist/esm/utils/resolvePKFields.mjs.map +0 -1
  115. package/src/internals/APIClient.ts +0 -1076
  116. package/src/internals/clientUtils.ts +0 -37
  117. package/src/internals/generateCustomOperationsProperty.ts +0 -112
  118. package/src/internals/operations/custom.ts +0 -492
  119. package/src/internals/operations/get.ts +0 -140
  120. package/src/internals/operations/indexQuery.ts +0 -170
  121. package/src/internals/operations/list.ts +0 -135
  122. package/src/internals/operations/observeQuery.ts +0 -146
  123. package/src/internals/operations/subscription.ts +0 -75
  124. package/src/internals/server/generateModelsProperty.ts +0 -97
  125. package/src/internals/utils/clientProperties/generateEnumsProperty.ts +0 -34
  126. package/src/internals/utils/clientProperties/generateModelsProperty.ts +0 -81
  127. package/src/utils/findIndexByFields.ts +0 -31
  128. package/src/utils/resolveOwnerFields.ts +0 -77
  129. package/src/utils/resolvePKFields.ts +0 -23
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.resolveOwnerFields = void 0;
5
- /**
6
- * Given an introspection schema model, returns all owner fields.
7
- *
8
- * @param model Model from an introspection schema
9
- * @returns List of owner field names
10
- */
11
- function resolveOwnerFields(model) {
12
- const ownerFields = new Set();
13
- for (const attr of model.attributes || []) {
14
- if (isAuthAttribute(attr)) {
15
- for (const rule of attr.properties.rules) {
16
- if (rule.allow === 'owner') {
17
- ownerFields.add(rule.ownerField || 'owner');
18
- }
19
- else if (rule.allow === 'groups' && rule.groupsField !== undefined) {
20
- // only valid for dynamic group(s)
21
- // static group auth will have an array of predefined groups in the attribute, groups: string[]
22
- // but `groupsField` will be undefined
23
- ownerFields.add(rule.groupsField);
24
- }
25
- }
26
- }
27
- }
28
- return Array.from(ownerFields);
29
- }
30
- exports.resolveOwnerFields = resolveOwnerFields;
31
- /**
32
- * Type guard that identifies an auth attribute with an attached rules list that
33
- * specifies an `allow` attribute at a minimum.
34
- *
35
- * @param attribute Any object. Ideally a model introspection schema model attribute
36
- * @returns True if given object is an auth attribute
37
- */
38
- function isAuthAttribute(attribute) {
39
- if (attribute?.type === 'auth') {
40
- if (typeof attribute?.properties === 'object') {
41
- if (Array.isArray(attribute?.properties?.rules)) {
42
- return (attribute?.properties?.rules).every(rule => !!rule.allow);
43
- }
44
- }
45
- }
46
- return false;
47
- }
48
- //# sourceMappingURL=resolveOwnerFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveOwnerFields.js","sources":["../../../src/utils/resolveOwnerFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveOwnerFields = void 0;\n/**\n * Given an introspection schema model, returns all owner fields.\n *\n * @param model Model from an introspection schema\n * @returns List of owner field names\n */\nfunction resolveOwnerFields(model) {\n const ownerFields = new Set();\n for (const attr of model.attributes || []) {\n if (isAuthAttribute(attr)) {\n for (const rule of attr.properties.rules) {\n if (rule.allow === 'owner') {\n ownerFields.add(rule.ownerField || 'owner');\n }\n else if (rule.allow === 'groups' && rule.groupsField !== undefined) {\n // only valid for dynamic group(s)\n // static group auth will have an array of predefined groups in the attribute, groups: string[]\n // but `groupsField` will be undefined\n ownerFields.add(rule.groupsField);\n }\n }\n }\n }\n return Array.from(ownerFields);\n}\nexports.resolveOwnerFields = resolveOwnerFields;\n/**\n * Type guard that identifies an auth attribute with an attached rules list that\n * specifies an `allow` attribute at a minimum.\n *\n * @param attribute Any object. Ideally a model introspection schema model attribute\n * @returns True if given object is an auth attribute\n */\nfunction isAuthAttribute(attribute) {\n if (attribute?.type === 'auth') {\n if (typeof attribute?.properties === 'object') {\n if (Array.isArray(attribute?.properties?.rules)) {\n return (attribute?.properties?.rules).every(rule => !!rule.allow);\n }\n }\n }\n return false;\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAE;AACnC,IAAI,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE;AAC/C,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;AACnC,YAAY,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACtD,gBAAgB,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;AAC5C,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC;AAChE,iBAAiB;AACjB,qBAAqB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;AACpF;AACA;AACA;AACA,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACtD,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,SAAS,EAAE;AACpC,IAAI,IAAI,SAAS,EAAE,IAAI,KAAK,MAAM,EAAE;AACpC,QAAQ,IAAI,OAAO,SAAS,EAAE,UAAU,KAAK,QAAQ,EAAE;AACvD,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE;AAC7D,gBAAgB,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;"}
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.resolvePKFields = void 0;
5
- /**
6
- * Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key
7
- * as an array of field names.
8
- *
9
- * @param model The model object
10
- * @returns Array of field names
11
- */
12
- function resolvePKFields(model) {
13
- const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;
14
- return [primaryKeyFieldName, ...sortKeyFieldNames];
15
- }
16
- exports.resolvePKFields = resolvePKFields;
17
- //# sourceMappingURL=resolvePKFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolvePKFields.js","sources":["../../../src/utils/resolvePKFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolvePKFields = void 0;\n/**\n * Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key\n * as an array of field names.\n *\n * @param model The model object\n * @returns Array of field names\n */\nfunction resolvePKFields(model) {\n const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;\n return [primaryKeyFieldName, ...sortKeyFieldNames];\n}\nexports.resolvePKFields = resolvePKFields;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,KAAK,EAAE;AAChC,IAAI,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC;AAC5E,IAAI,OAAO,CAAC,mBAAmB,EAAE,GAAG,iBAAiB,CAAC,CAAC;AACvD,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
@@ -1,126 +0,0 @@
1
- import { GraphQLAuthMode, ModelIntrospectionSchema, SchemaModel, SchemaNonModel } from '@aws-amplify/core/internals/utils';
2
- import { CustomHeaders } from '@aws-amplify/data-schema-types';
3
- import { AuthModeParams, ClientWithModels, ListArgs, QueryArgs, V6Client } from '../types';
4
- import type { IndexMeta } from './operations/indexQuery';
5
- /**
6
- *
7
- * @param GraphQL response object
8
- * @returns response object with `items` properties flattened
9
- */
10
- export declare const flattenItems: (obj: Record<string, any>) => Record<string, any>;
11
- export declare function initializeModel(client: ClientWithModels, modelName: string, result: any[], modelIntrospection: ModelIntrospectionSchema, authMode: GraphQLAuthMode | undefined, authToken: string | undefined, context?: boolean): any[];
12
- export declare const graphQLOperationsInfo: {
13
- readonly CREATE: {
14
- readonly operationPrefix: "create";
15
- readonly usePlural: false;
16
- };
17
- readonly READ: {
18
- readonly operationPrefix: "get";
19
- readonly usePlural: false;
20
- };
21
- readonly UPDATE: {
22
- readonly operationPrefix: "update";
23
- readonly usePlural: false;
24
- };
25
- readonly DELETE: {
26
- readonly operationPrefix: "delete";
27
- readonly usePlural: false;
28
- };
29
- readonly LIST: {
30
- readonly operationPrefix: "list";
31
- readonly usePlural: true;
32
- };
33
- readonly INDEX_QUERY: {
34
- readonly operationPrefix: "";
35
- readonly usePlural: false;
36
- };
37
- readonly ONCREATE: {
38
- readonly operationPrefix: "onCreate";
39
- readonly usePlural: false;
40
- };
41
- readonly ONUPDATE: {
42
- readonly operationPrefix: "onUpdate";
43
- readonly usePlural: false;
44
- };
45
- readonly ONDELETE: {
46
- readonly operationPrefix: "onDelete";
47
- readonly usePlural: false;
48
- };
49
- readonly OBSERVE_QUERY: {
50
- readonly operationPrefix: "observeQuery";
51
- readonly usePlural: false;
52
- };
53
- };
54
- export type ModelOperation = keyof typeof graphQLOperationsInfo;
55
- export declare const getDefaultSelectionSetForNonModelWithIR: (nonModelDefinition: SchemaNonModel, modelIntrospection: ModelIntrospectionSchema) => Record<string, unknown>;
56
- /**
57
- * Generates nested Custom Selection Set IR from path
58
- *
59
- * @param modelDefinitions
60
- * @param modelName
61
- * @param selectionSet - array of object paths
62
- * @example
63
- * ### Given
64
- * `selectionSet = ['id', 'comments.post.id']`
65
- * ### Returns
66
- * ```ts
67
- * {
68
- * id: '',
69
- * comments: {
70
- * items: { post: { id: '' } }
71
- * }
72
- * }
73
- * ```
74
- */
75
- export declare function customSelectionSetToIR(modelIntrospection: ModelIntrospectionSchema, modelName: string, selectionSet: string[]): Record<string, string | object>;
76
- /**
77
- * Stringifies selection set IR
78
- * * @example
79
- * ### Given
80
- * ```ts
81
- * {
82
- * id: '',
83
- * comments: {
84
- * items: { post: { id: '' } }
85
- * }
86
- * }
87
- * ```
88
- * ### Returns
89
- * `'id comments { items { post { id } } }'`
90
- */
91
- export declare function selectionSetIRToString(obj: Record<string, string | any>): string;
92
- export declare function generateSelectionSet(modelIntrospection: ModelIntrospectionSchema, modelName: string, selectionSet?: string[]): string;
93
- export declare function generateGraphQLDocument(modelIntrospection: ModelIntrospectionSchema, modelName: string, modelOperation: ModelOperation, listArgs?: ListArgs | QueryArgs, indexMeta?: IndexMeta): string;
94
- export declare function buildGraphQLVariables(modelDefinition: SchemaModel, operation: ModelOperation, arg: QueryArgs | undefined, modelIntrospection: ModelIntrospectionSchema, indexMeta?: IndexMeta): object;
95
- /**
96
- * Iterates over mutation input values and resolves any model inputs to their corresponding join fields/values
97
- *
98
- * @example
99
- * ### Usage
100
- * ```ts
101
- * const result = normalizeMutationInput({ post: post }, model, modelDefinition);
102
- * ```
103
- * ### Result
104
- * ```ts
105
- * { postId: "abc123" }
106
- * ```
107
- *
108
- */
109
- export declare function normalizeMutationInput(mutationInput: QueryArgs, model: SchemaModel, modelIntrospection: ModelIntrospectionSchema): QueryArgs;
110
- /**
111
- * Produces a parameter object that can contains auth mode/token overrides
112
- * only if present in either `options` (first) or configured on the `client`
113
- * as a fallback.
114
- *
115
- * @param client Configured client from `generateClient`
116
- * @param options Args/Options object from call site.
117
- * @returns
118
- */
119
- export declare function authModeParams(client: ClientWithModels, options?: AuthModeParams): AuthModeParams;
120
- /**
121
- * Retrieves custom headers from either the client or request options.
122
- * @param client V6Client | V6ClientSSRRequest | V6ClientSSRCookies - for extracting client headers
123
- * @param requestHeaders {@link CustomHeaders} - request headers
124
- * @returns custom headers as {@link CustomHeaders}
125
- */
126
- export declare function getCustomHeaders(client: V6Client | ClientWithModels, requestHeaders?: CustomHeaders): CustomHeaders;