@aws-amplify/data-schema 1.25.0 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Authorization.js.map +1 -1
- package/dist/cjs/CombineSchema.js.map +1 -1
- package/dist/cjs/CustomOperation.js.map +1 -1
- package/dist/cjs/Handler.js.map +1 -1
- package/dist/cjs/ModelField.js.map +1 -1
- package/dist/cjs/ModelIndex.js.map +1 -1
- package/dist/cjs/ModelRelationshipField.js.map +1 -1
- package/dist/cjs/ModelSchema.js.map +1 -1
- package/dist/cjs/ModelType.js.map +1 -1
- package/dist/cjs/RefType.js.map +1 -1
- package/dist/cjs/SchemaProcessor.js.map +1 -1
- package/dist/cjs/Validate.js.map +1 -1
- package/dist/cjs/a.js.map +1 -1
- package/dist/cjs/ai/ConversationSchemaProcessor.js.map +1 -1
- package/dist/cjs/ai/ConversationType.js.map +1 -1
- package/dist/cjs/internals/index.js.map +1 -1
- package/dist/cjs/runtime/addSchemaToClientWithInstance.js.map +1 -1
- package/dist/cjs/runtime/client/index.js.map +1 -1
- package/dist/cjs/runtime/client/index.v3.js.map +1 -1
- package/dist/cjs/runtime/index.js.map +1 -1
- package/dist/cjs/runtime/internals/APIClient.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/conversationMessageDeserializers.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/conversationMessageSerializers.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/conversationStreamEventDeserializers.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/convertItemToConversation.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createListConversationsFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createOnStreamEventFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/ai/createSendMessageFunction.js.map +1 -1
- package/dist/cjs/runtime/internals/cancellation.js.map +1 -1
- package/dist/cjs/runtime/internals/clientUtils.js.map +1 -1
- package/dist/cjs/runtime/internals/generateCustomOperationsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/index.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/custom.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/get.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/indexQuery.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/list.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/observeQuery.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/subscription.js.map +1 -1
- package/dist/cjs/runtime/internals/operations/utils.js.map +1 -1
- package/dist/cjs/runtime/internals/server/generateModelsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateConversationsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateEnumsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateGenerationsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js.map +1 -1
- package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js.map +1 -1
- package/dist/cjs/runtime/utils/findIndexByFields.js.map +1 -1
- package/dist/cjs/runtime/utils/index.js.map +1 -1
- package/dist/cjs/runtime/utils/resolveOwnerFields.js.map +1 -1
- package/dist/cjs/runtime/utils/selfAwareAsync.js.map +1 -1
- package/dist/cjs/util/index.js.map +1 -1
- package/dist/esm/Authorization.mjs.map +1 -1
- package/dist/esm/CombineSchema.mjs.map +1 -1
- package/dist/esm/CustomOperation.mjs.map +1 -1
- package/dist/esm/Handler.mjs.map +1 -1
- package/dist/esm/ModelField.mjs.map +1 -1
- package/dist/esm/ModelIndex.mjs.map +1 -1
- package/dist/esm/ModelRelationshipField.mjs.map +1 -1
- package/dist/esm/ModelSchema.mjs.map +1 -1
- package/dist/esm/ModelType.mjs.map +1 -1
- package/dist/esm/RefType.mjs.map +1 -1
- package/dist/esm/SchemaProcessor.mjs.map +1 -1
- package/dist/esm/Validate.mjs.map +1 -1
- package/dist/esm/ai/ConversationSchemaProcessor.mjs.map +1 -1
- package/dist/esm/ai/ConversationType.mjs.map +1 -1
- package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -1
- package/dist/esm/runtime/internals/APIClient.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/conversationMessageDeserializers.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/conversationMessageSerializers.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/conversationStreamEventDeserializers.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/convertItemToConversation.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createListConversationsFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createOnStreamEventFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/ai/createSendMessageFunction.mjs.map +1 -1
- package/dist/esm/runtime/internals/cancellation.mjs.map +1 -1
- package/dist/esm/runtime/internals/clientUtils.mjs.map +1 -1
- package/dist/esm/runtime/internals/generateCustomOperationsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/get.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/indexQuery.mjs +1 -1
- package/dist/esm/runtime/internals/operations/indexQuery.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/list.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/observeQuery.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/subscription.mjs.map +1 -1
- package/dist/esm/runtime/internals/operations/utils.mjs.map +1 -1
- package/dist/esm/runtime/internals/server/generateModelsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateConversationsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateGenerationsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -1
- package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs.map +1 -1
- package/dist/esm/runtime/utils/findIndexByFields.mjs.map +1 -1
- package/dist/esm/runtime/utils/resolveOwnerFields.mjs.map +1 -1
- package/dist/esm/runtime/utils/selfAwareAsync.mjs.map +1 -1
- package/dist/esm/util/Filters.d.ts +2 -2
- package/dist/meta/cjs.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/util/Filters.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authorization.js","sources":["../../src/Authorization.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.accessSchemaData = exports.accessData = exports.allowForConversations = exports.allowForCustomOperations = exports.allow = exports.ResourceOperations = exports.Operations = exports.Strategies = exports.CustomProviders = exports.GroupProviders = exports.OwnerProviders = exports.PrivateProviders = exports.PublicProviders = exports.Providers = void 0;\nconst __data = Symbol('data');\n/**\n * All possible providers.\n *\n * This list should not be used if you need to restrict available providers\n * according to an auth strategcy. E.g., `public` auth can only be facilitated\n * by `apiKey` and `identityPool` providers.\n */\nexports.Providers = [\n 'apiKey',\n 'identityPool',\n 'userPools',\n 'oidc',\n 'function',\n];\n/**\n * The subset of auth providers that can facilitate `public` auth.\n */\nexports.PublicProviders = ['apiKey', 'identityPool'];\n/**\n * The subset of auth providers that can facilitate `private` auth.\n */\nexports.PrivateProviders = ['userPools', 'oidc', 'identityPool'];\n/**\n * The subset of auth providers that can facilitate `owner` auth.\n */\nexports.OwnerProviders = ['userPools', 'oidc'];\n/**\n * The subset of auth providers that can facilitate `group` auth.\n */\nexports.GroupProviders = ['userPools', 'oidc'];\n/**\n * The subset of auth providers that can facilitate `custom` auth.\n */\nexports.CustomProviders = ['function'];\nexports.Strategies = [\n 'public',\n 'private',\n 'owner',\n 'groups',\n 'custom',\n];\n/**\n * The operations that can be performed against an API.\n */\nexports.Operations = [\n 'create',\n 'update',\n 'delete',\n 'read',\n 'get',\n 'list',\n 'sync',\n 'listen',\n 'search',\n];\n/**\n * The operations that can be performed against an API by a Lambda function.\n */\nexports.ResourceOperations = ['query', 'mutate', 'listen'];\n/**\n * Creates a shallow copy of an object with an individual field pruned away.\n *\n * @param original The original object to prune.\n * @param without The field to prune.\n * @returns The pruned object.\n */\nfunction omit(original, without) {\n const pruned = { ...original };\n delete pruned[without];\n return pruned;\n}\nfunction to(operations) {\n this[__data].operations = operations;\n return omit(this, 'to');\n}\n/**\n * Specifies a property of the identity JWT to use in place of `sub::username`\n * as the value to match against the owner field for authorization.\n *\n * @param this Authorization object to operate against.\n * @param property A property of identity JWT.\n * @returns A copy of the Authorization object with the claim attached.\n */\nfunction identityClaim(property) {\n this[__data].identityClaim = property;\n return omit(this, 'identityClaim');\n}\nfunction withClaimIn(property) {\n this[__data].groupClaim = property;\n return omit(this, 'withClaimIn');\n}\nfunction validateProvider(needle, haystack) {\n if (needle && !haystack.includes(needle)) {\n throw new Error(`Invalid provider (${needle}) given!`);\n }\n}\nfunction authData(defaults, builderMethods) {\n return {\n [__data]: {\n strategy: 'public',\n provider: undefined,\n operations: undefined,\n groupOrOwnerField: undefined,\n multiOwner: false,\n identityClaim: undefined,\n groups: undefined,\n ...defaults,\n },\n ...builderMethods,\n };\n}\n/**\n * Defines an authorization rule for your data models and fields. First choose an authorization strategy (`public`,\n * `private`, `owner`, `group`, or `custom`), then choose an auth provider (`apiKey`, `identitypool`, `userPools`, `oidc`, or `function`)\n * and optionally use `.to(...)` to specify the operations that can be performed against your data models and fields.\n */\nexports.allow = {\n /**\n * Authorize unauthenticated users by using API key based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n publicApiKey() {\n return authData({\n strategy: 'public',\n provider: 'apiKey',\n }, {\n to,\n });\n },\n /**\n * Authorize unauthenticated users by using IDENTITYPOOL based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n guest() {\n return authData({\n strategy: 'public',\n provider: 'identityPool',\n }, {\n to,\n });\n },\n /**\n * Authorize authenticated users. By default, `.authenticated()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.authenticated(\"identityPool\")` or `.authenticated(\"oidc\")` to use identityPool or OIDC based authorization for authenticated users.\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n authenticated(provider) {\n validateProvider(provider, exports.PrivateProviders);\n return authData({\n strategy: 'private',\n provider,\n }, {\n to,\n });\n },\n /**\n * Authorize access on a per-user (owner) basis. By setting owner-based authorization, a new `owner: a.string()`\n * field will be added to the model to store which user \"owns\" the item. Upon item creation, the \"owner field\" is\n * auto-populated with the authenticated user's information. If you want to specify which field should be used as\n * the owner field, you can use the `ownerDefinedIn` builder function instead.\n *\n * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.owner(\"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owner field, chain the\n * `.identityClaim(...)` method.\n *\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n owner(provider) {\n validateProvider(provider, exports.OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: 'owner',\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize access on a per-user (owner) basis with specifying which field should be used as the owner field.\n *\n * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.ownerDefinedIn(\"owner\", \"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owner field, chain the\n * `.identityClaim(...)` method.\n *\n * @param ownerField the field that contains the owner information\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n ownerDefinedIn(ownerField, provider) {\n validateProvider(provider, exports.OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: ownerField,\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize access for multi-user / multi-owner access. By setting multi-owner-based authorization, a new `owners: a.string().array()`\n * field will be added to the model to store which users \"own\" the item. Upon item creation, the \"owners field\" is\n * auto-populated with the authenticated user's information. To grant other users access to the item, append their user identifier into the `owners` array.\n *\n * You can specify which field should be used as the owners field by passing the `ownersField` parameter.\n *\n * By default, `.ownersDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.ownersDefinedIn(\"owners\", \"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owners field, chain the\n * `.identityClaim(...)` method.\n *\n * @param ownersField the field that contains the owners information\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n ownersDefinedIn(ownersField, provider) {\n validateProvider(provider, exports.OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: ownersField,\n multiOwner: true,\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize a specific user group. Provide the name of the specific user group to have access.\n *\n * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.group(\"group-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier, chain the\n * `.withClaimIn(...)` method.\n * @param group the name of the group to authorize\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n group(group, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups: [group],\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.\n *\n * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groups([\"group-a\", \"group-b\"], \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier, chain the\n * `.withClaimIn(...)` method.\n * @param groups the names of the group to authorize defined as an array\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groups(groups, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups,\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize if a user is part of a group defined in a data model field.\n *\n * By default, `.groupDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groupDefinedIn(\"field-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier within the groups field, chain the\n * `.withClaimIn(...)` method.\n * @param groupsField the field that should store the authorized user group information\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groupDefinedIn(groupsField, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groupOrOwnerField: groupsField,\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize if a user is part of a one of the groups defined in a data model field.\n *\n * By default, `.groupsDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groupsDefinedIn(\"field-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier within the groups field, chain the\n * `.withClaimIn(...)` method.\n * @param groupsField the field that should store the list of authorized user groups\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groupsDefinedIn(groupsField, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groupOrOwnerField: groupsField,\n multiOwner: true,\n }, {\n to,\n withClaimIn,\n });\n },\n custom(provider) {\n return authData({\n strategy: 'custom',\n provider,\n }, {\n to,\n });\n },\n resource(fn) {\n return resourceAuthData(fn, {\n to: resourceTo,\n });\n },\n};\n/**\n * This is a copy of the {@link allow} defined above, with modifications for custom operations.\n *\n * Removed builder methods:\n *\n * * `owner`\n * * `ownerDefinedIn`\n * * `ownersDefinedIn`\n * * `groupDefinedIn`\n * * `groupsDefinedIn`\n * * `resource`\n * * `.to()` builder method from each available rule builder\n */\nexports.allowForCustomOperations = {\n /**\n * Authorize unauthenticated users by using API key based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n publicApiKey() {\n return authData({\n strategy: 'public',\n provider: 'apiKey',\n }, {});\n },\n /**\n * Authorize unauthenticated users by using identityPool based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n guest() {\n return authData({\n strategy: 'public',\n provider: 'identityPool',\n }, {});\n },\n /**\n * Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.authenticated(\"identityPool\")` or `.authenticated(\"oidc\")` to use Identity Pool or OIDC based authorization for authenticated users.\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n authenticated(provider) {\n validateProvider(provider, exports.PrivateProviders);\n return authData({\n strategy: 'private',\n provider,\n }, {});\n },\n /**\n * Authorize a specific user group. Provide the name of the specific user group to have access.\n *\n * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.group(\"group-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * @param group the name of the group to authorize\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n group(group, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups: [group],\n }, {});\n },\n /**\n * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.\n *\n * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groups([\"group-a\", \"group-b\"], \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * @param groups the names of the group to authorize defined as an array\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groups(groups, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups,\n }, {});\n },\n custom(provider) {\n return authData({\n strategy: 'custom',\n provider,\n }, {});\n },\n};\nexports.allowForConversations = {\n owner() {\n return authData({\n strategy: 'owner',\n provider: 'userPools',\n }, {\n to,\n identityClaim,\n });\n },\n};\nfunction resourceTo(operations) {\n this[__data].operations = operations;\n return omit(this, 'to');\n}\nfunction resourceAuthData(resource, builderMethods) {\n return {\n [__data]: {\n strategy: 'resource',\n resource,\n },\n ...builderMethods,\n };\n}\nconst accessData = (authorization) => authorization[__data];\nexports.accessData = accessData;\n// TODO: delete when we make resource auth available at each level in the schema (model, field)\nconst accessSchemaData = (authorization) => authorization[__data];\nexports.accessSchemaData = accessSchemaData;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,SAAS,GAAG,MAAM;AACrW,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC,SAAS,GAAG;AACpB,IAAI,QAAQ;AACZ,IAAI,cAAc;AAClB,IAAI,WAAW;AACf,IAAI,MAAM;AACV,IAAI,UAAU;AACd,CAAC;AACD;AACA;AACA;AACA,OAAO,CAAC,eAAe,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC;AACpD;AACA;AACA;AACA,OAAO,CAAC,gBAAgB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC;AAChE;AACA;AACA;AACA,OAAO,CAAC,cAAc,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;AAC9C;AACA;AACA;AACA,OAAO,CAAC,cAAc,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;AAC9C;AACA;AACA;AACA,OA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,CAAC,MAAM,CAAC;AAC3D,OAAO,CAAC,UAAU,GAAG,UAAU;AAC/B;AACA,MAAM,gBAAgB,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,CAAC;AACjE,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
|
|
1
|
+
{"version":3,"file":"Authorization.js","sources":["../../src/Authorization.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.accessSchemaData = exports.accessData = exports.allowForConversations = exports.allowForCustomOperations = exports.allow = exports.ResourceOperations = exports.Operations = exports.Strategies = exports.CustomProviders = exports.GroupProviders = exports.OwnerProviders = exports.PrivateProviders = exports.PublicProviders = exports.Providers = void 0;\nconst __data = Symbol('data');\n/**\n * All possible providers.\n *\n * This list should not be used if you need to restrict available providers\n * according to an auth strategcy. E.g., `public` auth can only be facilitated\n * by `apiKey` and `identityPool` providers.\n */\nexports.Providers = [\n 'apiKey',\n 'identityPool',\n 'userPools',\n 'oidc',\n 'function',\n];\n/**\n * The subset of auth providers that can facilitate `public` auth.\n */\nexports.PublicProviders = ['apiKey', 'identityPool'];\n/**\n * The subset of auth providers that can facilitate `private` auth.\n */\nexports.PrivateProviders = ['userPools', 'oidc', 'identityPool'];\n/**\n * The subset of auth providers that can facilitate `owner` auth.\n */\nexports.OwnerProviders = ['userPools', 'oidc'];\n/**\n * The subset of auth providers that can facilitate `group` auth.\n */\nexports.GroupProviders = ['userPools', 'oidc'];\n/**\n * The subset of auth providers that can facilitate `custom` auth.\n */\nexports.CustomProviders = ['function'];\nexports.Strategies = [\n 'public',\n 'private',\n 'owner',\n 'groups',\n 'custom',\n];\n/**\n * The operations that can be performed against an API.\n */\nexports.Operations = [\n 'create',\n 'update',\n 'delete',\n 'read',\n 'get',\n 'list',\n 'sync',\n 'listen',\n 'search',\n];\n/**\n * The operations that can be performed against an API by a Lambda function.\n */\nexports.ResourceOperations = ['query', 'mutate', 'listen'];\n/**\n * Creates a shallow copy of an object with an individual field pruned away.\n *\n * @param original The original object to prune.\n * @param without The field to prune.\n * @returns The pruned object.\n */\nfunction omit(original, without) {\n const pruned = { ...original };\n delete pruned[without];\n return pruned;\n}\nfunction to(operations) {\n this[__data].operations = operations;\n return omit(this, 'to');\n}\n/**\n * Specifies a property of the identity JWT to use in place of `sub::username`\n * as the value to match against the owner field for authorization.\n *\n * @param this Authorization object to operate against.\n * @param property A property of identity JWT.\n * @returns A copy of the Authorization object with the claim attached.\n */\nfunction identityClaim(property) {\n this[__data].identityClaim = property;\n return omit(this, 'identityClaim');\n}\nfunction withClaimIn(property) {\n this[__data].groupClaim = property;\n return omit(this, 'withClaimIn');\n}\nfunction validateProvider(needle, haystack) {\n if (needle && !haystack.includes(needle)) {\n throw new Error(`Invalid provider (${needle}) given!`);\n }\n}\nfunction authData(defaults, builderMethods) {\n return {\n [__data]: {\n strategy: 'public',\n provider: undefined,\n operations: undefined,\n groupOrOwnerField: undefined,\n multiOwner: false,\n identityClaim: undefined,\n groups: undefined,\n ...defaults,\n },\n ...builderMethods,\n };\n}\n/**\n * Defines an authorization rule for your data models and fields. First choose an authorization strategy (`public`,\n * `private`, `owner`, `group`, or `custom`), then choose an auth provider (`apiKey`, `identitypool`, `userPools`, `oidc`, or `function`)\n * and optionally use `.to(...)` to specify the operations that can be performed against your data models and fields.\n */\nexports.allow = {\n /**\n * Authorize unauthenticated users by using API key based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n publicApiKey() {\n return authData({\n strategy: 'public',\n provider: 'apiKey',\n }, {\n to,\n });\n },\n /**\n * Authorize unauthenticated users by using IDENTITYPOOL based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n guest() {\n return authData({\n strategy: 'public',\n provider: 'identityPool',\n }, {\n to,\n });\n },\n /**\n * Authorize authenticated users. By default, `.authenticated()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.authenticated(\"identityPool\")` or `.authenticated(\"oidc\")` to use identityPool or OIDC based authorization for authenticated users.\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n authenticated(provider) {\n validateProvider(provider, exports.PrivateProviders);\n return authData({\n strategy: 'private',\n provider,\n }, {\n to,\n });\n },\n /**\n * Authorize access on a per-user (owner) basis. By setting owner-based authorization, a new `owner: a.string()`\n * field will be added to the model to store which user \"owns\" the item. Upon item creation, the \"owner field\" is\n * auto-populated with the authenticated user's information. If you want to specify which field should be used as\n * the owner field, you can use the `ownerDefinedIn` builder function instead.\n *\n * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.owner(\"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owner field, chain the\n * `.identityClaim(...)` method.\n *\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n owner(provider) {\n validateProvider(provider, exports.OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: 'owner',\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize access on a per-user (owner) basis with specifying which field should be used as the owner field.\n *\n * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.ownerDefinedIn(\"owner\", \"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owner field, chain the\n * `.identityClaim(...)` method.\n *\n * @param ownerField the field that contains the owner information\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n ownerDefinedIn(ownerField, provider) {\n validateProvider(provider, exports.OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: ownerField,\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize access for multi-user / multi-owner access. By setting multi-owner-based authorization, a new `owners: a.string().array()`\n * field will be added to the model to store which users \"own\" the item. Upon item creation, the \"owners field\" is\n * auto-populated with the authenticated user's information. To grant other users access to the item, append their user identifier into the `owners` array.\n *\n * You can specify which field should be used as the owners field by passing the `ownersField` parameter.\n *\n * By default, `.ownersDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.ownersDefinedIn(\"owners\", \"oidc\")` to use OIDC based authentication to designate the owner.\n *\n * To change the specific claim that should be used as the user identifier within the owners field, chain the\n * `.identityClaim(...)` method.\n *\n * @param ownersField the field that contains the owners information\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n ownersDefinedIn(ownersField, provider) {\n validateProvider(provider, exports.OwnerProviders);\n return authData({\n strategy: 'owner',\n provider,\n groupOrOwnerField: ownersField,\n multiOwner: true,\n }, {\n to,\n identityClaim,\n });\n },\n /**\n * Authorize a specific user group. Provide the name of the specific user group to have access.\n *\n * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.group(\"group-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier, chain the\n * `.withClaimIn(...)` method.\n * @param group the name of the group to authorize\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n group(group, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups: [group],\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.\n *\n * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groups([\"group-a\", \"group-b\"], \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier, chain the\n * `.withClaimIn(...)` method.\n * @param groups the names of the group to authorize defined as an array\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groups(groups, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups,\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize if a user is part of a group defined in a data model field.\n *\n * By default, `.groupDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groupDefinedIn(\"field-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier within the groups field, chain the\n * `.withClaimIn(...)` method.\n * @param groupsField the field that should store the authorized user group information\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groupDefinedIn(groupsField, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groupOrOwnerField: groupsField,\n }, {\n to,\n withClaimIn,\n });\n },\n /**\n * Authorize if a user is part of a one of the groups defined in a data model field.\n *\n * By default, `.groupsDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groupsDefinedIn(\"field-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * To change the specific claim that should be used as the user group identifier within the groups field, chain the\n * `.withClaimIn(...)` method.\n * @param groupsField the field that should store the list of authorized user groups\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groupsDefinedIn(groupsField, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groupOrOwnerField: groupsField,\n multiOwner: true,\n }, {\n to,\n withClaimIn,\n });\n },\n custom(provider) {\n return authData({\n strategy: 'custom',\n provider,\n }, {\n to,\n });\n },\n resource(fn) {\n return resourceAuthData(fn, {\n to: resourceTo,\n });\n },\n};\n/**\n * This is a copy of the {@link allow} defined above, with modifications for custom operations.\n *\n * Removed builder methods:\n *\n * * `owner`\n * * `ownerDefinedIn`\n * * `ownersDefinedIn`\n * * `groupDefinedIn`\n * * `groupsDefinedIn`\n * * `resource`\n * * `.to()` builder method from each available rule builder\n */\nexports.allowForCustomOperations = {\n /**\n * Authorize unauthenticated users by using API key based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n publicApiKey() {\n return authData({\n strategy: 'public',\n provider: 'apiKey',\n }, {});\n },\n /**\n * Authorize unauthenticated users by using identityPool based authorization.\n * @returns an authorization rule for unauthenticated users\n */\n guest() {\n return authData({\n strategy: 'public',\n provider: 'identityPool',\n }, {});\n },\n /**\n * Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.authenticated(\"identityPool\")` or `.authenticated(\"oidc\")` to use Identity Pool or OIDC based authorization for authenticated users.\n * @param provider the authentication provider - supports \"userPools\", \"identityPool\", or \"oidc\"\n * @returns an authorization rule for authenticated users\n */\n authenticated(provider) {\n validateProvider(provider, exports.PrivateProviders);\n return authData({\n strategy: 'private',\n provider,\n }, {});\n },\n /**\n * Authorize a specific user group. Provide the name of the specific user group to have access.\n *\n * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.group(\"group-name\", \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * @param group the name of the group to authorize\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n group(group, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups: [group],\n }, {});\n },\n /**\n * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.\n *\n * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally\n * use `.groups([\"group-a\", \"group-b\"], \"oidc\")` to use OIDC based authentication to designate the user group.\n *\n * @param groups the names of the group to authorize defined as an array\n * @param provider the authentication provider - supports \"userPools\" or \"oidc\"\n * @returns an authorization rule to grant access by a specific group\n */\n groups(groups, provider) {\n return authData({\n strategy: 'groups',\n provider,\n groups,\n }, {});\n },\n custom(provider) {\n return authData({\n strategy: 'custom',\n provider,\n }, {});\n },\n};\nexports.allowForConversations = {\n owner() {\n return authData({\n strategy: 'owner',\n provider: 'userPools',\n }, {\n to,\n identityClaim,\n });\n },\n};\nfunction resourceTo(operations) {\n this[__data].operations = operations;\n return omit(this, 'to');\n}\nfunction resourceAuthData(resource, builderMethods) {\n return {\n [__data]: {\n strategy: 'resource',\n resource,\n },\n ...builderMethods,\n };\n}\nconst accessData = (authorization) => authorization[__data];\nexports.accessData = accessData;\n// TODO: delete when we make resource auth available at each level in the schema (model, field)\nconst accessSchemaData = (authorization) => authorization[__data];\nexports.accessSchemaData = accessSchemaData;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,wBAAwB,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,SAAS,GAAG,MAAM;AACrW,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC,SAAS,GAAG;AACpB,IAAI,QAAQ;AACZ,IAAI,cAAc;AAClB,IAAI,WAAW;AACf,IAAI,MAAM;AACV,IAAI,UAAU;AACd,CAAC;AACD;AACA;AACA;AACA,OAAO,CAAC,eAAe,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC;AACpD;AACA;AACA;AACA,OAAO,CAAC,gBAAgB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC;AAChE;AACA;AACA;AACA,OAAO,CAAC,cAAc,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;AAC9C;AACA;AACA;AACA,OAAO,CAAC,cAAc,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;AAC9C;AACA;AACA;AACA,OAAO,CAAC,eAAe,GAAG,CAAC,UAAU,CAAC;AACtC,OAAO,CAAC,UAAU,GAAG;AACrB,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,OAAO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CAAC,MAAM,CAAC;AAC3D,OAAO,CAAC,UAAU,GAAG,UAAU;AAC/B;AACA,MAAM,gBAAgB,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,CAAC;AACjE,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CombineSchema.js","sources":["../../src/CombineSchema.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.combinedSchemaBrand = void 0;\nexports.combine = combine;\nconst util_1 = require(\"./util\");\nconst COMBINED_SCHEMA_LIMIT = 50;\nconst CombinedSchemaBrandName = 'CombinedSchema';\nexports.combinedSchemaBrand = (0, util_1.brand)(CombinedSchemaBrandName);\n/**\n * The interface for merging up to 50 schemas into a single API.\n * @param schemas The schemas to combine into a single API\n * @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)\n * or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)\n */\nfunction combine(schemas) {\n return internalCombine(schemas);\n}\nfunction internalCombine(schemas) {\n validateDuplicateTypeNames(schemas);\n const combined = {\n ...exports.combinedSchemaBrand,\n schemas: schemas,\n };\n for (const schema of combined.schemas) {\n schema.context = combined;\n }\n return combined;\n}\nfunction validateDuplicateTypeNames(schemas) {\n const allSchemaKeys = schemas.flatMap((s) => Object.keys(s.data.types));\n const keySet = new Set();\n const duplicateKeySet = new Set();\n allSchemaKeys.forEach((key) => {\n if (keySet.has(key)) {\n duplicateKeySet.add(key);\n }\n else {\n keySet.add(key);\n }\n });\n if (duplicateKeySet.size > 0) {\n throw new Error(`The schemas you are attempting to combine have a name collision. Please remove or rename ${Array.from(duplicateKeySet).join(', ')}.`);\n }\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,MAAM;AACpC,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAEhC,MAAM,uBAAuB,GAAG,gBAAgB;AAChD,OAAO,CAAC,mBAAmB,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC;AACxE;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,OAAO,EAAE;AAC1B,IAAI,OAAO,eAAe,CAAC,OAAO,CAAC;AACnC;AACA,SAAS,eAAe,CAAC,OAAO,EAAE;AAClC,IAAI,0BAA0B,CAAC,OAAO,CAAC;AACvC,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,GAAG,OAAO,CAAC,mBAAmB;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,KAAK;AACL,IAAI,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE;AAC3C,QAAQ,MAAM,CAAC,OAAO,GAAG,QAAQ;AACjC;
|
|
1
|
+
{"version":3,"file":"CombineSchema.js","sources":["../../src/CombineSchema.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.combinedSchemaBrand = void 0;\nexports.combine = combine;\nconst util_1 = require(\"./util\");\nconst COMBINED_SCHEMA_LIMIT = 50;\nconst CombinedSchemaBrandName = 'CombinedSchema';\nexports.combinedSchemaBrand = (0, util_1.brand)(CombinedSchemaBrandName);\n/**\n * The interface for merging up to 50 schemas into a single API.\n * @param schemas The schemas to combine into a single API\n * @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)\n * or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)\n */\nfunction combine(schemas) {\n return internalCombine(schemas);\n}\nfunction internalCombine(schemas) {\n validateDuplicateTypeNames(schemas);\n const combined = {\n ...exports.combinedSchemaBrand,\n schemas: schemas,\n };\n for (const schema of combined.schemas) {\n schema.context = combined;\n }\n return combined;\n}\nfunction validateDuplicateTypeNames(schemas) {\n const allSchemaKeys = schemas.flatMap((s) => Object.keys(s.data.types));\n const keySet = new Set();\n const duplicateKeySet = new Set();\n allSchemaKeys.forEach((key) => {\n if (keySet.has(key)) {\n duplicateKeySet.add(key);\n }\n else {\n keySet.add(key);\n }\n });\n if (duplicateKeySet.size > 0) {\n throw new Error(`The schemas you are attempting to combine have a name collision. Please remove or rename ${Array.from(duplicateKeySet).join(', ')}.`);\n }\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,MAAM;AACpC,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAEhC,MAAM,uBAAuB,GAAG,gBAAgB;AAChD,OAAO,CAAC,mBAAmB,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC;AACxE;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,OAAO,EAAE;AAC1B,IAAI,OAAO,eAAe,CAAC,OAAO,CAAC;AACnC;AACA,SAAS,eAAe,CAAC,OAAO,EAAE;AAClC,IAAI,0BAA0B,CAAC,OAAO,CAAC;AACvC,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,GAAG,OAAO,CAAC,mBAAmB;AACtC,QAAQ,OAAO,EAAE,OAAO;AACxB,KAAK;AACL,IAAI,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE;AAC3C,QAAQ,MAAM,CAAC,OAAO,GAAG,QAAQ;AACjC,IAAI;AACJ,IAAI,OAAO,QAAQ;AACnB;AACA,SAAS,0BAA0B,CAAC,OAAO,EAAE;AAC7C,IAAI,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3E,IAAI,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE;AAC5B,IAAI,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE;AACrC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK;AACnC,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AAC7B,YAAY,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC;AACpC,QAAQ;AACR,aAAa;AACb,YAAY,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;AAC3B,QAAQ;AACR,IAAI,CAAC,CAAC;AACN,IAAI,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;AAClC,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,yFAAyF,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9J,IAAI;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomOperation.js","sources":["../../src/CustomOperation.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CustomOperationNames = void 0;\nexports.query = query;\nexports.mutation = mutation;\nexports.subscription = subscription;\nexports.generation = generation;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst Brand_1 = require(\"./util/Brand\");\nconst queryBrand = 'queryCustomOperation';\nconst mutationBrand = 'mutationCustomOperation';\nconst subscriptionBrand = 'subscriptionCustomOperation';\nconst generationBrand = 'generationCustomOperation';\nexports.CustomOperationNames = [\n 'Query',\n 'Mutation',\n 'Subscription',\n 'Generation',\n];\nfunction brandedBuilder(builder, brandValue) {\n return { ...builder, ...(0, util_1.brand)(brandValue) };\n}\nfunction _custom(typeName, brand, input) {\n const data = {\n arguments: {},\n returnType: null,\n authorization: [],\n typeName: typeName,\n handlers: null,\n subscriptionSource: [],\n input,\n };\n const builder = brandedBuilder({\n arguments(args) {\n data.arguments = args;\n return this;\n },\n returns(returnType) {\n data.returnType = returnType;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allowForCustomOperations);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n handler(handlers) {\n data.handlers = Array.isArray(handlers)\n ? handlers\n : [handlers];\n if (lastHandlerIsAsyncFunction(handlers)) {\n data.returnType = eventInvocationResponse;\n }\n return this;\n },\n for(source) {\n data.subscriptionSource = Array.isArray(source) ? source : [source];\n return this;\n },\n }, brand);\n return { ...builder, data };\n}\n/**\n * Use a custom query to define an API request that will retrieve backend data.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * const schema = a.schema({\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler)),\n *\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n * });\n * @returns a custom query\n */\nfunction query() {\n return _custom('Query', queryBrand);\n}\n/**\n * Use a custom mutation to define an API request that will modify backend data or trigger a subscription event.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.string() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.publicApiKey()])\n * .handler(a.handler.function(echoHandler))\n * @returns a custom mutation\n */\nfunction mutation() {\n return _custom('Mutation', mutationBrand);\n}\n/**\n * Define a custom subscription to receive an event when a mutation is triggered\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-subscription/}\n * @example\n * // Subscribe to incoming messages\n * receive: a.subscription()\n * // subscribes to the 'publish' mutation\n * .for(a.ref('publish'))\n * // subscription handler to set custom filters\n * .handler(a.handler.custom({entry: './receive.js'}))\n * // authorization rules as to who can subscribe to the data\n * .authorization(allow => [allow.publicApiKey()]),\n * @returns a custom subscription\n */\nfunction subscription() {\n return _custom('Subscription', subscriptionBrand);\n}\nconst eventInvocationResponse = {\n data: {\n type: 'ref',\n link: 'EventInvocationResponse',\n valueRequired: false,\n array: false,\n arrayRequired: false,\n mutationOperations: [],\n authorization: [],\n },\n};\nfunction lastHandlerIsAsyncFunction(handlers) {\n const lastHandlerBrandSymbol = Array.isArray(handlers)\n ? handlers[handlers.length - 1][Brand_1.brandSymbol]\n : handlers[Brand_1.brandSymbol];\n return lastHandlerBrandSymbol === 'asyncFunctionHandler';\n}\n/**\n * Define an AI generation route for single request-response interaction with specified AI model.\n * @example\n * makeRecipe: a.generation({\n * aiModel: { resourcePath },\n * systemPrompt: 'Please make a recipe from the provided ingredients',\n * })\n * .arguments({ ingredients: a.string().array() })\n * .returns(a.ref(\"Recipe\"))\n * @returns a generation route definition\n */\nfunction generation(input) {\n return _custom('Generation', generationBrand, input);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,oBAAoB,GAAG,MAAM;AACrC,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,OAAO,CAAC,QAAQ,GAAG,QAAQ;AAC3B,OAAO,CAAC,YAAY,GAAG,YAAY;AACnC,OAAO,CAAC,UAAU,GAAG,UAAU;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;AACvC,MAAM,UAAU,GAAG,sBAAsB;AACzC,MAAM,aAAa,GAAG,yBAAyB;AAC/C,MAAM,iBAAiB,GAAG,6BAA6B;AACvD,MAAM,eAAe,GAAG,2BAA2B;AACnD,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,OAAO;AACX,IAAI,UAAU;AACd,IAAI,cAAc;AAClB,IAAI,YAAY;AAChB,CAAC;AACD,SAAS,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE;AAC7C,IAAI,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE;AAC3D;AACA,SAAS,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE;AACzC,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,SAAS,EAAE,EAAE;AACrB,QAAQ,UAAU,EAAE,IAAI;AACxB,QAAQ,aAAa,EAAE,EAAE;AACzB,QAAQ,QAAQ,EAAE,QAAQ;AAC1B,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,kBAAkB,EAAE,EAAE;AAC9B,QAAQ,KAAK;AACb,KAAK;AACL,IAAI,MAAM,OAAO,GAAG,cAAc,CAAC;AACnC,QAAQ,SAAS,CAAC,IAAI,EAAE;AACxB,YAAY,IAAI,CAAC,SAAS,GAAG,IAAI;AACjC,YAAY,OAAO,IAAI;AACvB,
|
|
1
|
+
{"version":3,"file":"CustomOperation.js","sources":["../../src/CustomOperation.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CustomOperationNames = void 0;\nexports.query = query;\nexports.mutation = mutation;\nexports.subscription = subscription;\nexports.generation = generation;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst Brand_1 = require(\"./util/Brand\");\nconst queryBrand = 'queryCustomOperation';\nconst mutationBrand = 'mutationCustomOperation';\nconst subscriptionBrand = 'subscriptionCustomOperation';\nconst generationBrand = 'generationCustomOperation';\nexports.CustomOperationNames = [\n 'Query',\n 'Mutation',\n 'Subscription',\n 'Generation',\n];\nfunction brandedBuilder(builder, brandValue) {\n return { ...builder, ...(0, util_1.brand)(brandValue) };\n}\nfunction _custom(typeName, brand, input) {\n const data = {\n arguments: {},\n returnType: null,\n authorization: [],\n typeName: typeName,\n handlers: null,\n subscriptionSource: [],\n input,\n };\n const builder = brandedBuilder({\n arguments(args) {\n data.arguments = args;\n return this;\n },\n returns(returnType) {\n data.returnType = returnType;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allowForCustomOperations);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n handler(handlers) {\n data.handlers = Array.isArray(handlers)\n ? handlers\n : [handlers];\n if (lastHandlerIsAsyncFunction(handlers)) {\n data.returnType = eventInvocationResponse;\n }\n return this;\n },\n for(source) {\n data.subscriptionSource = Array.isArray(source) ? source : [source];\n return this;\n },\n }, brand);\n return { ...builder, data };\n}\n/**\n * Use a custom query to define an API request that will retrieve backend data.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * const schema = a.schema({\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler)),\n *\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n * });\n * @returns a custom query\n */\nfunction query() {\n return _custom('Query', queryBrand);\n}\n/**\n * Use a custom mutation to define an API request that will modify backend data or trigger a subscription event.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @example\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.string() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.publicApiKey()])\n * .handler(a.handler.function(echoHandler))\n * @returns a custom mutation\n */\nfunction mutation() {\n return _custom('Mutation', mutationBrand);\n}\n/**\n * Define a custom subscription to receive an event when a mutation is triggered\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-subscription/}\n * @example\n * // Subscribe to incoming messages\n * receive: a.subscription()\n * // subscribes to the 'publish' mutation\n * .for(a.ref('publish'))\n * // subscription handler to set custom filters\n * .handler(a.handler.custom({entry: './receive.js'}))\n * // authorization rules as to who can subscribe to the data\n * .authorization(allow => [allow.publicApiKey()]),\n * @returns a custom subscription\n */\nfunction subscription() {\n return _custom('Subscription', subscriptionBrand);\n}\nconst eventInvocationResponse = {\n data: {\n type: 'ref',\n link: 'EventInvocationResponse',\n valueRequired: false,\n array: false,\n arrayRequired: false,\n mutationOperations: [],\n authorization: [],\n },\n};\nfunction lastHandlerIsAsyncFunction(handlers) {\n const lastHandlerBrandSymbol = Array.isArray(handlers)\n ? handlers[handlers.length - 1][Brand_1.brandSymbol]\n : handlers[Brand_1.brandSymbol];\n return lastHandlerBrandSymbol === 'asyncFunctionHandler';\n}\n/**\n * Define an AI generation route for single request-response interaction with specified AI model.\n * @example\n * makeRecipe: a.generation({\n * aiModel: { resourcePath },\n * systemPrompt: 'Please make a recipe from the provided ingredients',\n * })\n * .arguments({ ingredients: a.string().array() })\n * .returns(a.ref(\"Recipe\"))\n * @returns a generation route definition\n */\nfunction generation(input) {\n return _custom('Generation', generationBrand, input);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,oBAAoB,GAAG,MAAM;AACrC,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,OAAO,CAAC,QAAQ,GAAG,QAAQ;AAC3B,OAAO,CAAC,YAAY,GAAG,YAAY;AACnC,OAAO,CAAC,UAAU,GAAG,UAAU;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;AACvC,MAAM,UAAU,GAAG,sBAAsB;AACzC,MAAM,aAAa,GAAG,yBAAyB;AAC/C,MAAM,iBAAiB,GAAG,6BAA6B;AACvD,MAAM,eAAe,GAAG,2BAA2B;AACnD,OAAO,CAAC,oBAAoB,GAAG;AAC/B,IAAI,OAAO;AACX,IAAI,UAAU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;AAC9C,IAAI,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ;AACzD,UAAU,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW;AAC3D,UAAU,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC;AACvC,IAAI,OAAO,sBAAsB,KAAK,sBAAsB;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B,IAAI,OAAO,OAAO,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,CAAC;AACxD;;"}
|
package/dist/cjs/Handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.js","sources":["../../src/Handler.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handler = void 0;\nexports.getHandlerData = getHandlerData;\nconst util_1 = require(\"./util\");\nconst dataSymbol = Symbol('Data');\nfunction buildHandler(brandName) {\n return (0, util_1.brand)(brandName);\n}\nfunction getHandlerData(handler) {\n return handler[dataSymbol];\n}\n//#region handler.inlineSql\nconst inlineSqlBrand = 'inlineSql';\nfunction inlineSql(sql) {\n return { [dataSymbol]: sql, ...buildHandler(inlineSqlBrand) };\n}\n//#endregion\n//#region handler.sqlReference\nconst sqlReferenceBrand = 'sqlReference';\nfunction sqlReference(sqlFilePath) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { stack, entry: sqlFilePath },\n ...buildHandler(sqlReferenceBrand),\n };\n}\nconst customHandlerBrand = 'customHandler';\n/**\n * Use a custom JavaScript resolver to handle a query, mutation, or subscription.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/#step-2---configure-custom-business-logic-handler-code}\n * @param customHandler `{ entry: \"path-to-javascript-resolver-file.js\", dataSource: \"Data Source name added via \"backend.data.add*DataSoruce(...)\"}`\n * @returns A JavaScript resolver attached to the query, mutation, or subscription.\n * @example\n * const schema = a.schema({\n * Post: a.model({\n * content: a.string(),\n * likes: a.integer()\n * .authorization(allow => [allow.authenticated().to(['read'])])\n * }).authorization(allow => [\n * allow.owner(),\n * allow.authenticated().to(['read'])\n * ]),\n *\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.id() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.authenticated()])\n * .handler(a.handler.custom({\n * dataSource: a.ref('Post'),\n * entry: './increment-like.js'\n * }))\n * });\n */\nfunction custom(customHandler) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { ...customHandler, stack },\n ...buildHandler(customHandlerBrand),\n };\n}\nconst functionHandlerBrand = 'functionHandler';\nconst asyncFunctionHandlerBrand = 'asyncFunctionHandler';\n/**\n * Use a function created via `defineFunction` to handle the custom query/mutation/subscription. In your function handler,\n * you can use the `Schema[\"YOUR_QUERY_OR_MUTATION_NAME\"][\"functionHandler\"]` utility type to type the handler function.\n * @example\n * import {\n * type ClientSchema,\n * a,\n * defineData,\n * defineFunction // 1.Import \"defineFunction\" to create new functions\n * } from '@aws-amplify/backend';\n *\n * // 2. define a function\n * const echoHandler = defineFunction({\n * entry: './echo-handler/handler.ts'\n * })\n *\n * const schema = a.schema({\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n *\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler))\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @param fn A function created via `defineFunction`. Alternatively, you can pass in a \"string\" of the function name and pass\n * in a corresponding value into the `functionMap` property of defineData.\n * @returns A handler for the query / mutation / subscription\n */\nfunction fcn(fn) {\n return {\n [dataSymbol]: {\n handler: fn,\n invocationType: 'RequestResponse',\n },\n async() {\n return _async(this);\n },\n ...buildHandler(functionHandlerBrand),\n };\n}\nfunction _async(fnHandler) {\n return {\n [dataSymbol]: {\n handler: fnHandler[dataSymbol].handler,\n invocationType: 'Event',\n },\n ...buildHandler(asyncFunctionHandlerBrand),\n };\n}\n//#endregion\nexports.handler = {\n inlineSql,\n sqlReference,\n custom,\n function: fcn,\n};\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,OAAO,GAAG,MAAM;AACxB,OAAO,CAAC,cAAc,GAAG,cAAc;AACvC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;AACjC,SAAS,YAAY,CAAC,SAAS,EAAE;AACjC,IAAI,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC;AACvC;AACA,SAAS,cAAc,CAAC,OAAO,EAAE;AACjC,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC;AAC9B;AACA;AACA,MAAM,cAAc,GAAG,WAAW;AAClC,SAAS,SAAS,CAAC,GAAG,EAAE;AACxB,IAAI,OAAO,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,GAAG,YAAY,CAAC,cAAc,CAAC,EAAE;AACjE;AACA;AACA;AACA,MAAM,iBAAiB,GAAG,cAAc;AACxC,SAAS,YAAY,CAAC,WAAW,EAAE;AACnC;AACA,IAAI,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK;AACnC,IAAI,OAAO;AACX,QAAQ,CAAC,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE;AACnD,QAAQ,GAAG,YAAY,CAAC,iBAAiB,CAAC;AAC1C,KAAK;AACL;AACA,MAAM,kBAAkB,GAAG,eAAe;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,aAAa,EAAE;AAC/B;AACA,IAAI,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK;AACnC,IAAI,OAAO;AACX,QAAQ,CAAC,UAAU,GAAG,EAAE,GAAG,aAAa,EAAE,KAAK,EAAE;AACjD,QAAQ,GAAG,YAAY,CAAC,kBAAkB,CAAC;AAC3C,KAAK;AACL;AACA,MAAM,oBAAoB,GAAG,iBAAiB;AAC9C,MAAM,yBAAyB,GAAG,sBAAsB;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,GAAG,CAAC,EAAE,EAAE;AACjB,IAAI,OAAO;AACX,QAAQ,CAAC,UAAU,GAAG;AACtB,YAAY,OAAO,EAAE,EAAE;AACvB,YAAY,cAAc,EAAE,iBAAiB;AAC7C,SAAS;AACT,QAAQ,KAAK,GAAG;AAChB,YAAY,OAAO,MAAM,CAAC,IAAI,CAAC;AAC/B,
|
|
1
|
+
{"version":3,"file":"Handler.js","sources":["../../src/Handler.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.handler = void 0;\nexports.getHandlerData = getHandlerData;\nconst util_1 = require(\"./util\");\nconst dataSymbol = Symbol('Data');\nfunction buildHandler(brandName) {\n return (0, util_1.brand)(brandName);\n}\nfunction getHandlerData(handler) {\n return handler[dataSymbol];\n}\n//#region handler.inlineSql\nconst inlineSqlBrand = 'inlineSql';\nfunction inlineSql(sql) {\n return { [dataSymbol]: sql, ...buildHandler(inlineSqlBrand) };\n}\n//#endregion\n//#region handler.sqlReference\nconst sqlReferenceBrand = 'sqlReference';\nfunction sqlReference(sqlFilePath) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { stack, entry: sqlFilePath },\n ...buildHandler(sqlReferenceBrand),\n };\n}\nconst customHandlerBrand = 'customHandler';\n/**\n * Use a custom JavaScript resolver to handle a query, mutation, or subscription.\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/#step-2---configure-custom-business-logic-handler-code}\n * @param customHandler `{ entry: \"path-to-javascript-resolver-file.js\", dataSource: \"Data Source name added via \"backend.data.add*DataSoruce(...)\"}`\n * @returns A JavaScript resolver attached to the query, mutation, or subscription.\n * @example\n * const schema = a.schema({\n * Post: a.model({\n * content: a.string(),\n * likes: a.integer()\n * .authorization(allow => [allow.authenticated().to(['read'])])\n * }).authorization(allow => [\n * allow.owner(),\n * allow.authenticated().to(['read'])\n * ]),\n *\n * likePost: a\n * .mutation()\n * .arguments({ postId: a.id() })\n * .returns(a.ref('Post'))\n * .authorization(allow => [allow.authenticated()])\n * .handler(a.handler.custom({\n * dataSource: a.ref('Post'),\n * entry: './increment-like.js'\n * }))\n * });\n */\nfunction custom(customHandler) {\n // used to determine caller directory in order to resolve relative path downstream\n const stack = new Error().stack;\n return {\n [dataSymbol]: { ...customHandler, stack },\n ...buildHandler(customHandlerBrand),\n };\n}\nconst functionHandlerBrand = 'functionHandler';\nconst asyncFunctionHandlerBrand = 'asyncFunctionHandler';\n/**\n * Use a function created via `defineFunction` to handle the custom query/mutation/subscription. In your function handler,\n * you can use the `Schema[\"YOUR_QUERY_OR_MUTATION_NAME\"][\"functionHandler\"]` utility type to type the handler function.\n * @example\n * import {\n * type ClientSchema,\n * a,\n * defineData,\n * defineFunction // 1.Import \"defineFunction\" to create new functions\n * } from '@aws-amplify/backend';\n *\n * // 2. define a function\n * const echoHandler = defineFunction({\n * entry: './echo-handler/handler.ts'\n * })\n *\n * const schema = a.schema({\n * EchoResponse: a.customType({\n * content: a.string(),\n * executionDuration: a.float()\n * }),\n *\n * echo: a\n * .query()\n * .arguments({ content: a.string() })\n * .returns(a.ref('EchoResponse'))\n * .authorization(allow => [allow.publicApiKey()])\n * // 3. set the function has the handler\n * .handler(a.handler.function(echoHandler))\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/}\n * @param fn A function created via `defineFunction`. Alternatively, you can pass in a \"string\" of the function name and pass\n * in a corresponding value into the `functionMap` property of defineData.\n * @returns A handler for the query / mutation / subscription\n */\nfunction fcn(fn) {\n return {\n [dataSymbol]: {\n handler: fn,\n invocationType: 'RequestResponse',\n },\n async() {\n return _async(this);\n },\n ...buildHandler(functionHandlerBrand),\n };\n}\nfunction _async(fnHandler) {\n return {\n [dataSymbol]: {\n handler: fnHandler[dataSymbol].handler,\n invocationType: 'Event',\n },\n ...buildHandler(asyncFunctionHandlerBrand),\n };\n}\n//#endregion\nexports.handler = {\n inlineSql,\n sqlReference,\n custom,\n function: fcn,\n};\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,OAAO,GAAG,MAAM;AACxB,OAAO,CAAC,cAAc,GAAG,cAAc;AACvC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;AACjC,SAAS,YAAY,CAAC,SAAS,EAAE;AACjC,IAAI,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC;AACvC;AACA,SAAS,cAAc,CAAC,OAAO,EAAE;AACjC,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC;AAC9B;AACA;AACA,MAAM,cAAc,GAAG,WAAW;AAClC,SAAS,SAAS,CAAC,GAAG,EAAE;AACxB,IAAI,OAAO,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,GAAG,YAAY,CAAC,cAAc,CAAC,EAAE;A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AoB,CAAC;AAC7C,KAAK;AACL;AACA,SAAS,MAAM,CAAC,SAAS,EAAE;AAC3B,IAAI,OAAO;AACX,QAAQ,CAAC,UAAU,GAAG;AACtB,YAAY,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO;AAClD,YAAY,cAAc,EAAE,OAAO;AACnC,SAAS;AACT,QAAQ,GAAG,YAAY,CAAC,yBAAyB,CAAC;AAClD,KAAK;AACL;AACA;AACA,OAAO,CAAC,OAAO,GAAG;AAClB,IAAI,SAAS;AACb,IAAI,YAAY;AAChB,IAAI,MAAM;AACV,IAAI,QAAQ,EAAE,GAAG;AACjB,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelField.js","sources":["../../src/ModelField.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ModelFieldDataType = exports.ModelFieldType = exports.__generated = exports.__auth = void 0;\nexports.id = id;\nexports.string = string;\nexports.integer = integer;\nexports.float = float;\nexports.boolean = boolean;\nexports.date = date;\nexports.time = time;\nexports.datetime = datetime;\nexports.timestamp = timestamp;\nexports.email = email;\nexports.json = json;\nexports.phone = phone;\nexports.url = url;\nexports.ipAddress = ipAddress;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst Validate_1 = require(\"./Validate\");\n/**\n * Used to \"attach\" auth types to ModelField without exposing them on the builder.\n */\nexports.__auth = Symbol('__auth');\n/**\n * Used by `.default()` to represent a generated field (SQL).\n */\nexports.__generated = Symbol('__generated');\nconst brandName = 'modelField';\nconst internal = Symbol('internal');\nvar ModelFieldType;\n(function (ModelFieldType) {\n ModelFieldType[\"Id\"] = \"ID\";\n ModelFieldType[\"String\"] = \"String\";\n ModelFieldType[\"Integer\"] = \"Int\";\n ModelFieldType[\"Float\"] = \"Float\";\n ModelFieldType[\"Boolean\"] = \"Boolean\";\n ModelFieldType[\"Date\"] = \"AWSDate\";\n ModelFieldType[\"Time\"] = \"AWSTime\";\n ModelFieldType[\"DateTime\"] = \"AWSDateTime\";\n ModelFieldType[\"Timestamp\"] = \"AWSTimestamp\";\n ModelFieldType[\"Email\"] = \"AWSEmail\";\n ModelFieldType[\"JSON\"] = \"AWSJSON\";\n ModelFieldType[\"Phone\"] = \"AWSPhone\";\n ModelFieldType[\"Url\"] = \"AWSURL\";\n ModelFieldType[\"IPAddress\"] = \"AWSIPAddress\";\n})(ModelFieldType || (exports.ModelFieldType = ModelFieldType = {}));\nvar ModelFieldDataType;\n(function (ModelFieldDataType) {\n ModelFieldDataType[\"String\"] = \"string\";\n ModelFieldDataType[\"Number\"] = \"number\";\n ModelFieldDataType[\"Boolean\"] = \"boolean\";\n ModelFieldDataType[\"Date\"] = \"Date\";\n ModelFieldDataType[\"JSON\"] = \"any\";\n})(ModelFieldDataType || (exports.ModelFieldDataType = ModelFieldDataType = {}));\n/**\n * Model Field Implementation\n *\n * @typeParam T - holds the JS data type of the field; invoking the public methods changes this type accordingly\n * @example\n * string() => T = string | null\n * string().array() => T = Array<string | null> | null\n * string().array().required() => T = Array<string | null>\n * string().required().array().required() => T = Array<string>\n *\n * @param fieldType - stores the GraphQL data type of the field\n */\nfunction _field(fieldType) {\n const _meta = {\n lastInvokedMethod: null,\n };\n const data = {\n fieldType,\n required: false,\n array: false,\n arrayRequired: false,\n default: undefined,\n authorization: [],\n validation: [],\n };\n const builder = {\n required() {\n if (_meta.lastInvokedMethod === 'array') {\n data.arrayRequired = true;\n }\n else {\n data.required = true;\n }\n _meta.lastInvokedMethod = 'required';\n return this;\n },\n array() {\n data.array = true;\n _meta.lastInvokedMethod = 'array';\n return this;\n },\n default(val) {\n data.default = typeof val === 'undefined' ? exports.__generated : val;\n _meta.lastInvokedMethod = 'default';\n return this;\n },\n authorization(callback) {\n const { resource: _, ...rest } = Authorization_1.allow;\n const rules = callback(rest);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n _meta.lastInvokedMethod = 'authorization';\n return this;\n },\n validate(callback) {\n const { builder, getRules } = (0, Validate_1.createValidationBuilder)();\n callback(builder);\n data.validation = getRules();\n _meta.lastInvokedMethod = 'validate';\n return this;\n },\n ...(0, util_1.brand)(brandName),\n [internal]() {\n return this;\n },\n };\n return { ...builder, data };\n}\n/**\n * A unique identifier scalar type. This scalar is serialized like a String but isn't meant to be human-readable.\n * If not specified on create operations, a ULID will be auto-generated service-side.\n * @returns ID field definition\n */\nfunction id() {\n return _field(ModelFieldType.Id);\n}\n/**\n * A string scalar type that is represented server-side as a UTF-8 character sequence.\n * @returns string field definition\n */\nfunction string() {\n return _field(ModelFieldType.String);\n}\n/**\n * An integer scalar type with a supported value range between -(2^31) and 2^31-1.\n * @returns integer field definition\n */\nfunction integer() {\n return _field(ModelFieldType.Integer);\n}\n/**\n * A float scalar type following represented server-side as an IEEE 754 floating point value.\n * @returns float field definition\n */\nfunction float() {\n return _field(ModelFieldType.Float);\n}\n/**\n * A boolean scalar type that can be either true or false.\n * @returns boolean field definition\n */\nfunction boolean() {\n return _field(ModelFieldType.Boolean);\n}\n/**\n * A date scalar type that is represented server-side as an extended ISO 8601 date string in the format `YYYY-MM-DD`.\n * @returns date field definition\n */\nfunction date() {\n return _field(ModelFieldType.Date);\n}\n/**\n * A time scalar type that is represented server-side as an extended ISO 8601 time string in the format `hh:mm:ss.sss`.\n * @returns time field definition\n */\nfunction time() {\n return _field(ModelFieldType.Time);\n}\n/**\n * A date time scalar type that is represented server-side as an extended ISO 8601 date and time string in the format `YYYY-MM-DDThh:mm:ss.sssZ`.\n * @returns datetime field definition\n */\nfunction datetime() {\n return _field(ModelFieldType.DateTime);\n}\n/**\n * A timestamp scalar type that is represented by an integer value of the number of seconds before or after `1970-01-01-T00:00Z`.\n * @returns timestamp field definition\n */\nfunction timestamp() {\n return _field(ModelFieldType.Timestamp);\n}\n/**\n * An email scalar type that is represented server-side in the format `local-part@domain-part` as defined by RFC 822.\n * @returns email field definition\n */\nfunction email() {\n return _field(ModelFieldType.Email);\n}\n/**\n * A JSON scalar type that is automatically parsed and loaded server-side as maps, lists, or scalar values\n * rather than as the literal input strings.\n * @returns JSON field definition\n */\nfunction json() {\n return _field(ModelFieldType.JSON);\n}\n/**\n * A phone number scalar type thas is stored as a string server-side. Phone numbers can contain either spaces\n * or hyphens to separate digit groups. Phone numbers without a country code are assumed to be US/North American numbers adhering\n * to the North American Numbering Plan.\n * @returns phone number field definition\n */\nfunction phone() {\n return _field(ModelFieldType.Phone);\n}\n/**\n * A URL scalar type as defined by RFC 1738. For example, https://www.amazon.com/dp/B000NZW3KC/ or mailto:example@example.com.\n * URLs must contain a schema (http, mailto) and can't contain two forward slashes (//) in the path part.\n * @returns URL field definition\n */\nfunction url() {\n return _field(ModelFieldType.Url);\n}\n/**\n * A valid IPv4 or IPv6 address scalar type. IPv4 addresses are expected in quad-dotted notation (123.12.34.56). IPv6 addresses\n * are expected in non-bracketed, colon-separated format (1a2b:3c4b:🔢4567). You can include an optional CIDR suffix (123.45.67.89/16)\n * to indicate subnet mask.\n * @returns IP address field definition\n */\nfunction ipAddress() {\n return _field(ModelFieldType.IPAddress);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;AACnG,OAAO,CAAC,EAAE,GAAG,EAAE;AACf,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,OAAO,CAAC,QAAQ,GAAG,QAAQ;AAC3B,OAAO,CAAC,SAAS,GAAG,SAAS;A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AACjB,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,GAAG,GAAG;AACf,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,SAAS,GAAG;AACrB,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC;AAC3C;;"}
|
|
1
|
+
{"version":3,"file":"ModelField.js","sources":["../../src/ModelField.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ModelFieldDataType = exports.ModelFieldType = exports.__generated = exports.__auth = void 0;\nexports.id = id;\nexports.string = string;\nexports.integer = integer;\nexports.float = float;\nexports.boolean = boolean;\nexports.date = date;\nexports.time = time;\nexports.datetime = datetime;\nexports.timestamp = timestamp;\nexports.email = email;\nexports.json = json;\nexports.phone = phone;\nexports.url = url;\nexports.ipAddress = ipAddress;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst Validate_1 = require(\"./Validate\");\n/**\n * Used to \"attach\" auth types to ModelField without exposing them on the builder.\n */\nexports.__auth = Symbol('__auth');\n/**\n * Used by `.default()` to represent a generated field (SQL).\n */\nexports.__generated = Symbol('__generated');\nconst brandName = 'modelField';\nconst internal = Symbol('internal');\nvar ModelFieldType;\n(function (ModelFieldType) {\n ModelFieldType[\"Id\"] = \"ID\";\n ModelFieldType[\"String\"] = \"String\";\n ModelFieldType[\"Integer\"] = \"Int\";\n ModelFieldType[\"Float\"] = \"Float\";\n ModelFieldType[\"Boolean\"] = \"Boolean\";\n ModelFieldType[\"Date\"] = \"AWSDate\";\n ModelFieldType[\"Time\"] = \"AWSTime\";\n ModelFieldType[\"DateTime\"] = \"AWSDateTime\";\n ModelFieldType[\"Timestamp\"] = \"AWSTimestamp\";\n ModelFieldType[\"Email\"] = \"AWSEmail\";\n ModelFieldType[\"JSON\"] = \"AWSJSON\";\n ModelFieldType[\"Phone\"] = \"AWSPhone\";\n ModelFieldType[\"Url\"] = \"AWSURL\";\n ModelFieldType[\"IPAddress\"] = \"AWSIPAddress\";\n})(ModelFieldType || (exports.ModelFieldType = ModelFieldType = {}));\nvar ModelFieldDataType;\n(function (ModelFieldDataType) {\n ModelFieldDataType[\"String\"] = \"string\";\n ModelFieldDataType[\"Number\"] = \"number\";\n ModelFieldDataType[\"Boolean\"] = \"boolean\";\n ModelFieldDataType[\"Date\"] = \"Date\";\n ModelFieldDataType[\"JSON\"] = \"any\";\n})(ModelFieldDataType || (exports.ModelFieldDataType = ModelFieldDataType = {}));\n/**\n * Model Field Implementation\n *\n * @typeParam T - holds the JS data type of the field; invoking the public methods changes this type accordingly\n * @example\n * string() => T = string | null\n * string().array() => T = Array<string | null> | null\n * string().array().required() => T = Array<string | null>\n * string().required().array().required() => T = Array<string>\n *\n * @param fieldType - stores the GraphQL data type of the field\n */\nfunction _field(fieldType) {\n const _meta = {\n lastInvokedMethod: null,\n };\n const data = {\n fieldType,\n required: false,\n array: false,\n arrayRequired: false,\n default: undefined,\n authorization: [],\n validation: [],\n };\n const builder = {\n required() {\n if (_meta.lastInvokedMethod === 'array') {\n data.arrayRequired = true;\n }\n else {\n data.required = true;\n }\n _meta.lastInvokedMethod = 'required';\n return this;\n },\n array() {\n data.array = true;\n _meta.lastInvokedMethod = 'array';\n return this;\n },\n default(val) {\n data.default = typeof val === 'undefined' ? exports.__generated : val;\n _meta.lastInvokedMethod = 'default';\n return this;\n },\n authorization(callback) {\n const { resource: _, ...rest } = Authorization_1.allow;\n const rules = callback(rest);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n _meta.lastInvokedMethod = 'authorization';\n return this;\n },\n validate(callback) {\n const { builder, getRules } = (0, Validate_1.createValidationBuilder)();\n callback(builder);\n data.validation = getRules();\n _meta.lastInvokedMethod = 'validate';\n return this;\n },\n ...(0, util_1.brand)(brandName),\n [internal]() {\n return this;\n },\n };\n return { ...builder, data };\n}\n/**\n * A unique identifier scalar type. This scalar is serialized like a String but isn't meant to be human-readable.\n * If not specified on create operations, a ULID will be auto-generated service-side.\n * @returns ID field definition\n */\nfunction id() {\n return _field(ModelFieldType.Id);\n}\n/**\n * A string scalar type that is represented server-side as a UTF-8 character sequence.\n * @returns string field definition\n */\nfunction string() {\n return _field(ModelFieldType.String);\n}\n/**\n * An integer scalar type with a supported value range between -(2^31) and 2^31-1.\n * @returns integer field definition\n */\nfunction integer() {\n return _field(ModelFieldType.Integer);\n}\n/**\n * A float scalar type following represented server-side as an IEEE 754 floating point value.\n * @returns float field definition\n */\nfunction float() {\n return _field(ModelFieldType.Float);\n}\n/**\n * A boolean scalar type that can be either true or false.\n * @returns boolean field definition\n */\nfunction boolean() {\n return _field(ModelFieldType.Boolean);\n}\n/**\n * A date scalar type that is represented server-side as an extended ISO 8601 date string in the format `YYYY-MM-DD`.\n * @returns date field definition\n */\nfunction date() {\n return _field(ModelFieldType.Date);\n}\n/**\n * A time scalar type that is represented server-side as an extended ISO 8601 time string in the format `hh:mm:ss.sss`.\n * @returns time field definition\n */\nfunction time() {\n return _field(ModelFieldType.Time);\n}\n/**\n * A date time scalar type that is represented server-side as an extended ISO 8601 date and time string in the format `YYYY-MM-DDThh:mm:ss.sssZ`.\n * @returns datetime field definition\n */\nfunction datetime() {\n return _field(ModelFieldType.DateTime);\n}\n/**\n * A timestamp scalar type that is represented by an integer value of the number of seconds before or after `1970-01-01-T00:00Z`.\n * @returns timestamp field definition\n */\nfunction timestamp() {\n return _field(ModelFieldType.Timestamp);\n}\n/**\n * An email scalar type that is represented server-side in the format `local-part@domain-part` as defined by RFC 822.\n * @returns email field definition\n */\nfunction email() {\n return _field(ModelFieldType.Email);\n}\n/**\n * A JSON scalar type that is automatically parsed and loaded server-side as maps, lists, or scalar values\n * rather than as the literal input strings.\n * @returns JSON field definition\n */\nfunction json() {\n return _field(ModelFieldType.JSON);\n}\n/**\n * A phone number scalar type thas is stored as a string server-side. Phone numbers can contain either spaces\n * or hyphens to separate digit groups. Phone numbers without a country code are assumed to be US/North American numbers adhering\n * to the North American Numbering Plan.\n * @returns phone number field definition\n */\nfunction phone() {\n return _field(ModelFieldType.Phone);\n}\n/**\n * A URL scalar type as defined by RFC 1738. For example, https://www.amazon.com/dp/B000NZW3KC/ or mailto:example@example.com.\n * URLs must contain a schema (http, mailto) and can't contain two forward slashes (//) in the path part.\n * @returns URL field definition\n */\nfunction url() {\n return _field(ModelFieldType.Url);\n}\n/**\n * A valid IPv4 or IPv6 address scalar type. IPv4 addresses are expected in quad-dotted notation (123.12.34.56). IPv6 addresses\n * are expected in non-bracketed, colon-separated format (1a2b:3c4b:🔢4567). You can include an optional CIDR suffix (123.45.67.89/16)\n * to indicate subnet mask.\n * @returns IP address field definition\n */\nfunction ipAddress() {\n return _field(ModelFieldType.IPAddress);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;AACnG,OAAO,CAAC,EAAE,GAAG,EAAE;AACf,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,OAAO,CAAC,QAAQ,GAAG,QAAQ;AAC3B,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,OAAO,CAAC,GAAG,GAAG,GAAG;AACj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AAS,GAAG,GAAG;AACf,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,SAAS,GAAG;AACrB,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC;AAC3C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelIndex.js","sources":["../../src/ModelIndex.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.modelIndex = modelIndex;\nconst util_1 = require(\"./util\");\nconst brandName = 'modelIndexType';\nfunction _modelIndex(partitionKeyFieldName) {\n const data = {\n partitionKey: partitionKeyFieldName,\n sortKeys: [],\n indexName: '',\n queryField: '',\n projectionType: 'ALL',\n nonKeyAttributes: undefined,\n };\n const builder = {\n sortKeys(sortKeys) {\n data.sortKeys = sortKeys;\n return this;\n },\n name(name) {\n data.indexName = name;\n return this;\n },\n queryField(field) {\n data.queryField = field;\n return this;\n },\n projection(type, ...args) {\n data.projectionType = type;\n if (type === 'INCLUDE') {\n data.nonKeyAttributes = args[0];\n }\n return this;\n },\n ...(0, util_1.brand)(brandName),\n };\n return { ...builder, data };\n}\nfunction modelIndex(partitionKeyFieldName) {\n return _modelIndex(partitionKeyFieldName);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,UAAU,GAAG,UAAU;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,SAAS,GAAG,gBAAgB;AAClC,SAAS,WAAW,CAAC,qBAAqB,EAAE;AAC5C,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,YAAY,EAAE,qBAAqB;AAC3C,QAAQ,QAAQ,EAAE,EAAE;AACpB,QAAQ,SAAS,EAAE,EAAE;AACrB,QAAQ,UAAU,EAAE,EAAE;AACtB,QAAQ,cAAc,EAAE,KAAK;AAC7B,QAAQ,gBAAgB,EAAE,SAAS;AACnC,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,QAAQ,CAAC,QAAQ,EAAE;AAC3B,YAAY,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACpC,YAAY,OAAO,IAAI;AACvB,
|
|
1
|
+
{"version":3,"file":"ModelIndex.js","sources":["../../src/ModelIndex.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.modelIndex = modelIndex;\nconst util_1 = require(\"./util\");\nconst brandName = 'modelIndexType';\nfunction _modelIndex(partitionKeyFieldName) {\n const data = {\n partitionKey: partitionKeyFieldName,\n sortKeys: [],\n indexName: '',\n queryField: '',\n projectionType: 'ALL',\n nonKeyAttributes: undefined,\n };\n const builder = {\n sortKeys(sortKeys) {\n data.sortKeys = sortKeys;\n return this;\n },\n name(name) {\n data.indexName = name;\n return this;\n },\n queryField(field) {\n data.queryField = field;\n return this;\n },\n projection(type, ...args) {\n data.projectionType = type;\n if (type === 'INCLUDE') {\n data.nonKeyAttributes = args[0];\n }\n return this;\n },\n ...(0, util_1.brand)(brandName),\n };\n return { ...builder, data };\n}\nfunction modelIndex(partitionKeyFieldName) {\n return _modelIndex(partitionKeyFieldName);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,UAAU,GAAG,UAAU;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,SAAS,GAAG,gBAAgB;AAClC,SAAS,WAAW,CAAC,qBAAqB,EAAE;AAC5C,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,YAAY,EAAE,qBAAqB;AAC3C,QAAQ,QAAQ,EAAE,EAAE;AACpB,QAAQ,SAAS,EAAE,EAAE;AACrB,QAAQ,UAAU,EAAE,EAAE;AACtB,QAAQ,cAAc,EAAE,KAAK;AAC7B,QAAQ,gBAAgB,EAAE,SAAS;AACnC,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,QAAQ,CAAC,QAAQ,EAAE;AAC3B,YAAY,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACpC,YAAY,OAAO,IAAI;AACvB,QAAQ,CAAC;AACT,QAAQ,IAAI,CAAC,IAAI,EAAE;AACnB,YAAY,IAAI,CAAC,SAAS,GAAG,IAAI;AACjC,YAAY,OAAO,IAAI;AACvB,QAAQ,CAAC;AACT,QAAQ,UAAU,CAAC,KAAK,EAAE;AAC1B,YAAY,IAAI,CAAC,UAAU,GAAG,KAAK;AACnC,YAAY,OAAO,IAAI;AACvB,QAAQ,CAAC;AACT,QAAQ,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE;AAClC,YAAY,IAAI,CAAC,cAAc,GAAG,IAAI;AACtC,YAAY,IAAI,IAAI,KAAK,SAAS,EAAE;AACpC,gBAAgB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/C,YAAY;AACZ,YAAY,OAAO,IAAI;AACvB,QAAQ,CAAC;AACT,QAAQ,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC;AACvC,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE;AAC/B;AACA,SAAS,UAAU,CAAC,qBAAqB,EAAE;AAC3C,IAAI,OAAO,WAAW,CAAC,qBAAqB,CAAC;AAC7C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelRelationshipField.js","sources":["../../src/ModelRelationshipField.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ModelRelationshipTypes = exports.__auth = void 0;\nexports.hasOne = hasOne;\nexports.hasMany = hasMany;\nexports.belongsTo = belongsTo;\nconst Authorization_1 = require(\"./Authorization\");\n/**\n * Used to \"attach\" auth types to ModelField without exposing them on the builder.\n */\nexports.__auth = Symbol('__auth');\nconst brandName = 'modelRelationshipField';\n/**\n * Model relationship types\n */\nvar ModelRelationshipTypes;\n(function (ModelRelationshipTypes) {\n ModelRelationshipTypes[\"hasOne\"] = \"hasOne\";\n ModelRelationshipTypes[\"hasMany\"] = \"hasMany\";\n ModelRelationshipTypes[\"belongsTo\"] = \"belongsTo\";\n})(ModelRelationshipTypes || (exports.ModelRelationshipTypes = ModelRelationshipTypes = {}));\nconst relationshipModifiers = [\n 'required',\n 'valueRequired',\n 'authorization',\n];\nconst relationModifierMap = {\n belongsTo: ['authorization'],\n hasMany: ['valueRequired', 'authorization'],\n hasOne: ['required', 'authorization'],\n};\nfunction _modelRelationshipField(type, relatedModel, references) {\n const data = {\n relatedModel,\n type,\n fieldType: 'model',\n array: false,\n valueRequired: false,\n arrayRequired: false,\n references,\n authorization: [],\n };\n data.array = type === 'hasMany';\n const relationshipBuilderFunctions = {\n required() {\n data.arrayRequired = true;\n return this;\n },\n valueRequired() {\n data.valueRequired = true;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n };\n const builder = Object.fromEntries(relationModifierMap[type].map((key) => [\n key,\n relationshipBuilderFunctions[key],\n ]));\n return {\n ...builder,\n data,\n };\n}\n/**\n * Create one-to-one relationship between two models using the `hasOne(\"MODEL_NAME\", \"REFERENCE_FIELD(s)\")` method.\n * A hasOne relationship always uses a reference to the related model's identifier. Typically this is the `id` field\n * unless overwritten with the `identifier()` method.\n * @example\n * const schema = a.schema({\n * Cart: a.model({\n * items: a.string().required().array(),\n * // 1. Create reference field\n * customerId: a.id(),\n * // 2. Create relationship field with the reference field\n * customer: a.belongsTo('Customer', 'customerId'),\n * }),\n * Customer: a.model({\n * name: a.string(),\n * // 3. Create relationship field with the reference field\n * // from the Cart model\n * activeCart: a.hasOne('Cart', 'customerId')\n * }),\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/data-modeling/relationships/#model-a-one-to-one-relationship}\n * @param relatedModel the name of the related model\n * @param references the field(s) that should be used to reference the related model\n * @returns a one-to-one relationship definition\n */\nfunction hasOne(relatedModel, references) {\n return _modelRelationshipField(ModelRelationshipTypes.hasOne, relatedModel, Array.isArray(references) ? references : [references]);\n}\n/**\n * Create a one-directional one-to-many relationship between two models using the `hasMany(\"MODEL_NAME\", \"REFERENCE_FIELD(s)\")` method.\n * @example\n * const schema = a.schema({\n * Member: a.model({\n * name: a.string().required(),\n * // 1. Create a reference field\n * teamId: a.id(),\n * // 2. Create a belongsTo relationship with the reference field\n * team: a.belongsTo('Team', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n *\n * Team: a.model({\n * mantra: a.string().required(),\n * // 3. Create a hasMany relationship with the reference field\n * // from the `Member`s model.\n * members: a.hasMany('Member', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/data-modeling/relationships/#model-one-to-many-relationships}\n * @param relatedModel the name of the related model\n * @param references the field(s) that should be used to reference the related model\n * @returns a one-to-many relationship definition\n */\nfunction hasMany(relatedModel, references) {\n return _modelRelationshipField(ModelRelationshipTypes.hasMany, relatedModel, Array.isArray(references) ? references : [references]);\n}\n/**\n * Use `belongsTo()` to create a field to query the related `hasOne()` or `hasMany()` relationship.\n * The belongsTo() method requires that a hasOne() or hasMany() relationship already exists from\n * parent to the related model.\n *\n * @example\n * // one-to-many relationship\n * const schema = a.schema({\n * Member: a.model({\n * name: a.string().required(),\n * // 1. Create a reference field\n * teamId: a.id(),\n * // 2. Create a belongsTo relationship with the reference field\n * team: a.belongsTo('Team', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n *\n * Team: a.model({\n * mantra: a.string().required(),\n * // 3. Create a hasMany relationship with the reference field\n * // from the `Member`s model.\n * members: a.hasMany('Member', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n * });\n * @example\n * // one-to-one relationship\n * const schema = a.schema({\n * Cart: a.model({\n * items: a.string().required().array(),\n * // 1. Create reference field\n * customerId: a.id(),\n * // 2. Create relationship field with the reference field\n * customer: a.belongsTo('Customer', 'customerId'),\n * }),\n * Customer: a.model({\n * name: a.string(),\n * // 3. Create relationship field with the reference field\n * // from the Cart model\n * activeCart: a.hasOne('Cart', 'customerId')\n * }),\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/data-modeling/relationships/}\n * @param relatedModel name of the related `.hasOne()` or `.hasMany()` model\n * @param references the field(s) that should be used to reference the related model\n * @returns a belong-to relationship definition\n */\nfunction belongsTo(relatedModel, references) {\n return _modelRelationshipField(ModelRelationshipTypes.belongsTo, relatedModel, Array.isArray(references) ? references : [references]);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;AACxD,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD;AACA;AACA;AACA,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC;AACA;AACA;AACA,IAAI,sBAAsB;AAC1B,CAAC,UAAU,sBAAsB,EAAE;AACnC,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAC/C,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS;AACjD,IAAI,sBAAsB,CAAC,WAAW,CAAC,GAAG,WAAW;AACrD,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,sBAAsB,GAAG,sBAAsB,GAAG,EAAE,CAAC,CAAC;AAM5F,MAAM,mBAAmB,GAAG;AAC5B,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC;AAChC,IAAI,OAAO,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC;AAC/C,IAAI,MAAM,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC;AACzC,CAAC;AACD,SAAS,uBAAuB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE;AACjE,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,YAAY;AACpB,QAAQ,IAAI;AACZ,QAAQ,SAAS,EAAE,OAAO;AAC1B,QAAQ,KAAK,EAAE,KAAK;AACpB,QAAQ,aAAa,EAAE,KAAK;AAC5B,QAAQ,aAAa,EAAE,KAAK;AAC5B,QAAQ,UAAU;AAClB,QAAQ,aAAa,EAAE,EAAE;AACzB,KAAK;AACL,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,SAAS;AACnC,IAAI,MAAM,4BAA4B,GAAG;AACzC,QAAQ,QAAQ,GAAG;AACnB,YAAY,IAAI,CAAC,aAAa,GAAG,IAAI;AACrC,YAAY,OAAO,IAAI;AACvB,
|
|
1
|
+
{"version":3,"file":"ModelRelationshipField.js","sources":["../../src/ModelRelationshipField.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ModelRelationshipTypes = exports.__auth = void 0;\nexports.hasOne = hasOne;\nexports.hasMany = hasMany;\nexports.belongsTo = belongsTo;\nconst Authorization_1 = require(\"./Authorization\");\n/**\n * Used to \"attach\" auth types to ModelField without exposing them on the builder.\n */\nexports.__auth = Symbol('__auth');\nconst brandName = 'modelRelationshipField';\n/**\n * Model relationship types\n */\nvar ModelRelationshipTypes;\n(function (ModelRelationshipTypes) {\n ModelRelationshipTypes[\"hasOne\"] = \"hasOne\";\n ModelRelationshipTypes[\"hasMany\"] = \"hasMany\";\n ModelRelationshipTypes[\"belongsTo\"] = \"belongsTo\";\n})(ModelRelationshipTypes || (exports.ModelRelationshipTypes = ModelRelationshipTypes = {}));\nconst relationshipModifiers = [\n 'required',\n 'valueRequired',\n 'authorization',\n];\nconst relationModifierMap = {\n belongsTo: ['authorization'],\n hasMany: ['valueRequired', 'authorization'],\n hasOne: ['required', 'authorization'],\n};\nfunction _modelRelationshipField(type, relatedModel, references) {\n const data = {\n relatedModel,\n type,\n fieldType: 'model',\n array: false,\n valueRequired: false,\n arrayRequired: false,\n references,\n authorization: [],\n };\n data.array = type === 'hasMany';\n const relationshipBuilderFunctions = {\n required() {\n data.arrayRequired = true;\n return this;\n },\n valueRequired() {\n data.valueRequired = true;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n };\n const builder = Object.fromEntries(relationModifierMap[type].map((key) => [\n key,\n relationshipBuilderFunctions[key],\n ]));\n return {\n ...builder,\n data,\n };\n}\n/**\n * Create one-to-one relationship between two models using the `hasOne(\"MODEL_NAME\", \"REFERENCE_FIELD(s)\")` method.\n * A hasOne relationship always uses a reference to the related model's identifier. Typically this is the `id` field\n * unless overwritten with the `identifier()` method.\n * @example\n * const schema = a.schema({\n * Cart: a.model({\n * items: a.string().required().array(),\n * // 1. Create reference field\n * customerId: a.id(),\n * // 2. Create relationship field with the reference field\n * customer: a.belongsTo('Customer', 'customerId'),\n * }),\n * Customer: a.model({\n * name: a.string(),\n * // 3. Create relationship field with the reference field\n * // from the Cart model\n * activeCart: a.hasOne('Cart', 'customerId')\n * }),\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/data-modeling/relationships/#model-a-one-to-one-relationship}\n * @param relatedModel the name of the related model\n * @param references the field(s) that should be used to reference the related model\n * @returns a one-to-one relationship definition\n */\nfunction hasOne(relatedModel, references) {\n return _modelRelationshipField(ModelRelationshipTypes.hasOne, relatedModel, Array.isArray(references) ? references : [references]);\n}\n/**\n * Create a one-directional one-to-many relationship between two models using the `hasMany(\"MODEL_NAME\", \"REFERENCE_FIELD(s)\")` method.\n * @example\n * const schema = a.schema({\n * Member: a.model({\n * name: a.string().required(),\n * // 1. Create a reference field\n * teamId: a.id(),\n * // 2. Create a belongsTo relationship with the reference field\n * team: a.belongsTo('Team', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n *\n * Team: a.model({\n * mantra: a.string().required(),\n * // 3. Create a hasMany relationship with the reference field\n * // from the `Member`s model.\n * members: a.hasMany('Member', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/data-modeling/relationships/#model-one-to-many-relationships}\n * @param relatedModel the name of the related model\n * @param references the field(s) that should be used to reference the related model\n * @returns a one-to-many relationship definition\n */\nfunction hasMany(relatedModel, references) {\n return _modelRelationshipField(ModelRelationshipTypes.hasMany, relatedModel, Array.isArray(references) ? references : [references]);\n}\n/**\n * Use `belongsTo()` to create a field to query the related `hasOne()` or `hasMany()` relationship.\n * The belongsTo() method requires that a hasOne() or hasMany() relationship already exists from\n * parent to the related model.\n *\n * @example\n * // one-to-many relationship\n * const schema = a.schema({\n * Member: a.model({\n * name: a.string().required(),\n * // 1. Create a reference field\n * teamId: a.id(),\n * // 2. Create a belongsTo relationship with the reference field\n * team: a.belongsTo('Team', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n *\n * Team: a.model({\n * mantra: a.string().required(),\n * // 3. Create a hasMany relationship with the reference field\n * // from the `Member`s model.\n * members: a.hasMany('Member', 'teamId'),\n * })\n * .authorization(allow => [allow.publicApiKey()]),\n * });\n * @example\n * // one-to-one relationship\n * const schema = a.schema({\n * Cart: a.model({\n * items: a.string().required().array(),\n * // 1. Create reference field\n * customerId: a.id(),\n * // 2. Create relationship field with the reference field\n * customer: a.belongsTo('Customer', 'customerId'),\n * }),\n * Customer: a.model({\n * name: a.string(),\n * // 3. Create relationship field with the reference field\n * // from the Cart model\n * activeCart: a.hasOne('Cart', 'customerId')\n * }),\n * });\n * @see {@link https://docs.amplify.aws/react/build-a-backend/data/data-modeling/relationships/}\n * @param relatedModel name of the related `.hasOne()` or `.hasMany()` model\n * @param references the field(s) that should be used to reference the related model\n * @returns a belong-to relationship definition\n */\nfunction belongsTo(relatedModel, references) {\n return _modelRelationshipField(ModelRelationshipTypes.belongsTo, relatedModel, Array.isArray(references) ? references : [references]);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;AACxD,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB,OAAO,CAAC,OAAO,GAAG,OAAO;AACzB,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD;AACA;AACA;AACA,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC;AACA;AACA;AACA,IAAI,sBAAsB;AAC1B,CAAC,UAAU,sBAAsB,EAAE;AACnC,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAC/C,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS;AACjD,IAAI,sBAAsB,CAAC,WAAW,CAAC,GAAG,WAAW;AACrD,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,sBAAsB,GAAG,sBAAsB,GAAG,EAAE,CAAC,CAAC;AAM5F,MAAM,mBAAmB,GAAG;AAC5B,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC;AAChC,IAAI,OAAO,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC;AAC/C,IAAI,MAAM,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC;AACzC,CAAC;AACD,SAAS,uBAAuB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE;AACjE,IAAI,MAAM,IAAI,GAA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AAE,UAAU,EAAE;AAC1C,IAAI,OAAO,uBAAuB,CAAC,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC;AACtI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,YAAY,EAAE,UAAU,EAAE;AAC3C,IAAI,OAAO,uBAAuB,CAAC,sBAAsB,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC;AACvI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE;AAC7C,IAAI,OAAO,uBAAuB,CAAC,sBAAsB,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC;AACzI;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelSchema.js","sources":["../../src/ModelSchema.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.schema = exports.isModelSchema = exports.ddbSchemaBrandName = exports.rdsSchemaBrand = exports.rdsSchemaBrandName = void 0;\nexports.configure = configure;\nexports.isCustomPathData = isCustomPathData;\nconst ModelType_1 = require(\"./ModelType\");\nconst SchemaProcessor_1 = require(\"./SchemaProcessor\");\nconst Authorization_1 = require(\"./Authorization\");\nconst util_1 = require(\"./util\");\nexports.rdsSchemaBrandName = 'RDSSchema';\nexports.rdsSchemaBrand = (0, util_1.brand)(exports.rdsSchemaBrandName);\nexports.ddbSchemaBrandName = 'DDBSchema';\nconst ddbSchemaBrand = (0, util_1.brand)(exports.ddbSchemaBrandName);\n/**\n * Filter the schema types down to only include the ModelTypes as SchemaModelType\n *\n * @param schemaContents The object containing all SchemaContent for this schema\n * @returns Only the schemaContents that are ModelTypes, coerced to the SchemaModelType surface\n */\nconst filterSchemaModelTypes = (schemaContents) => {\n const modelTypes = {};\n if (schemaContents) {\n Object.entries(schemaContents).forEach(([key, content]) => {\n if ((0, ModelType_1.isSchemaModelType)(content)) {\n modelTypes[key] = content;\n }\n });\n }\n return modelTypes;\n};\n/**\n * Model Schema type guard\n * @param schema - api-next ModelSchema or string\n * @returns true if the given value is a ModelSchema\n */\nconst isModelSchema = (schema) => {\n return typeof schema === 'object' && schema.data !== undefined;\n};\nexports.isModelSchema = isModelSchema;\n/**\n * Ensures that only supported entities are being added to the SQL schema through `addToSchema`\n * Models are not supported for brownfield SQL\n *\n * @param types - purposely widened to ModelSchemaContents, because we need to validate at runtime that a model is not being passed in here\n */\nfunction validateAddToSchema(types) {\n for (const [name, type] of Object.entries(types)) {\n if ((0, util_1.getBrand)(type) === 'modelType') {\n throw new Error(`Invalid value specified for ${name} in addToSchema(). Models cannot be manually added to a SQL schema.`);\n }\n }\n}\nfunction _rdsSchema(types, config) {\n const data = {\n types,\n authorization: [],\n configuration: config,\n };\n const models = filterSchemaModelTypes(data.types);\n return {\n data,\n models,\n transform() {\n const internalSchema = {\n data,\n context: this.context,\n };\n return (0, SchemaProcessor_1.processSchema)({ schema: internalSchema });\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n this.data.authorization = Array.isArray(rules) ? rules : [rules];\n const { authorization: _, ...rest } = this;\n return rest;\n },\n addToSchema(types) {\n validateAddToSchema(types);\n this.data.types = { ...this.data.types, ...types };\n const { addToSchema: _, ...rest } = this;\n return rest;\n },\n addQueries(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addQueries: _, ...rest } = this;\n return rest;\n },\n addMutations(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addMutations: _, ...rest } = this;\n return rest;\n },\n addSubscriptions(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addSubscriptions: _, ...rest } = this;\n return rest;\n },\n setAuthorization(callback) {\n callback(models, this);\n const { setAuthorization: _, ...rest } = this;\n return rest;\n },\n setRelationships(callback) {\n const { setRelationships: _, ...rest } = this;\n // The relationships are added via `models.<Model>.relationships`\n // modifiers that's being called within the callback. They are modifying\n // by references on each model, so there is not anything else to be done\n // here.\n callback(models);\n return rest;\n },\n renameModels(callback) {\n const { renameModels: _, ...rest } = this;\n // returns an array of tuples [curName, newName]\n const changeLog = callback();\n changeLog.forEach(([curName, newName]) => {\n const currentType = data.types[curName];\n if (currentType === undefined) {\n throw new Error(`Invalid renameModels call. ${curName} is not defined in the schema`);\n }\n if (typeof newName !== 'string' || newName.length < 1) {\n throw new Error(`Invalid renameModels call. New name must be a non-empty string. Received: \"${newName}\"`);\n }\n models[newName] = currentType;\n data.types[newName] = currentType;\n models[newName].data.originalName = curName;\n delete models[curName];\n delete data.types[curName];\n });\n return rest;\n },\n ...exports.rdsSchemaBrand,\n };\n}\nfunction _ddbSchema(types, config) {\n const data = {\n types,\n authorization: [],\n configuration: config,\n };\n return {\n data,\n transform() {\n const internalSchema = {\n data,\n context: this.context,\n };\n return (0, SchemaProcessor_1.processSchema)({ schema: internalSchema });\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n this.data.authorization = Array.isArray(rules) ? rules : [rules];\n const { authorization: _, ...rest } = this;\n return rest;\n },\n models: filterSchemaModelTypes(data.types),\n ...ddbSchemaBrand,\n };\n}\nfunction bindConfigToSchema(config) {\n return (types) => {\n return (config.database.engine === 'dynamodb'\n ? _ddbSchema(types, config)\n : _rdsSchema(types, config));\n };\n}\n/**\n * The API and data model definition for Amplify Data. Pass in `{ <NAME>: a.model(...) }` to create a database table\n * and exposes CRUDL operations via an API.\n * @param types The API and data model definition\n * @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)\n * or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)\n */\nexports.schema = bindConfigToSchema({ database: { engine: 'dynamodb' } });\n/**\n * Configure wraps schema definition with non-default config to allow usecases other than\n * the default DynamoDB use-case.\n *\n * @param config The SchemaConfig augments the schema with content like the database type\n * @returns\n */\nfunction configure(config) {\n return {\n schema: bindConfigToSchema(config),\n };\n}\nfunction isCustomPathData(obj) {\n return ('stack' in obj &&\n (typeof obj.stack === 'undefined' || typeof obj.stack === 'string') &&\n 'entry' in obj &&\n typeof obj.entry === 'string');\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,kBAAkB,GAAG,MAAM;AAClI,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;AAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;AAC1C,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACtD,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,OAAO,CAAC,kBAAkB,GAAG,WAAW;AACxC,OAAO,CAAC,cAAc,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC;AACtE,OAAO,CAAC,kBAAkB,GAAG,WAAW;AACxC,MAAM,cAAc,GAAG,IAA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3,"file":"ModelSchema.js","sources":["../../src/ModelSchema.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.schema = exports.isModelSchema = exports.ddbSchemaBrandName = exports.rdsSchemaBrand = exports.rdsSchemaBrandName = void 0;\nexports.configure = configure;\nexports.isCustomPathData = isCustomPathData;\nconst ModelType_1 = require(\"./ModelType\");\nconst SchemaProcessor_1 = require(\"./SchemaProcessor\");\nconst Authorization_1 = require(\"./Authorization\");\nconst util_1 = require(\"./util\");\nexports.rdsSchemaBrandName = 'RDSSchema';\nexports.rdsSchemaBrand = (0, util_1.brand)(exports.rdsSchemaBrandName);\nexports.ddbSchemaBrandName = 'DDBSchema';\nconst ddbSchemaBrand = (0, util_1.brand)(exports.ddbSchemaBrandName);\n/**\n * Filter the schema types down to only include the ModelTypes as SchemaModelType\n *\n * @param schemaContents The object containing all SchemaContent for this schema\n * @returns Only the schemaContents that are ModelTypes, coerced to the SchemaModelType surface\n */\nconst filterSchemaModelTypes = (schemaContents) => {\n const modelTypes = {};\n if (schemaContents) {\n Object.entries(schemaContents).forEach(([key, content]) => {\n if ((0, ModelType_1.isSchemaModelType)(content)) {\n modelTypes[key] = content;\n }\n });\n }\n return modelTypes;\n};\n/**\n * Model Schema type guard\n * @param schema - api-next ModelSchema or string\n * @returns true if the given value is a ModelSchema\n */\nconst isModelSchema = (schema) => {\n return typeof schema === 'object' && schema.data !== undefined;\n};\nexports.isModelSchema = isModelSchema;\n/**\n * Ensures that only supported entities are being added to the SQL schema through `addToSchema`\n * Models are not supported for brownfield SQL\n *\n * @param types - purposely widened to ModelSchemaContents, because we need to validate at runtime that a model is not being passed in here\n */\nfunction validateAddToSchema(types) {\n for (const [name, type] of Object.entries(types)) {\n if ((0, util_1.getBrand)(type) === 'modelType') {\n throw new Error(`Invalid value specified for ${name} in addToSchema(). Models cannot be manually added to a SQL schema.`);\n }\n }\n}\nfunction _rdsSchema(types, config) {\n const data = {\n types,\n authorization: [],\n configuration: config,\n };\n const models = filterSchemaModelTypes(data.types);\n return {\n data,\n models,\n transform() {\n const internalSchema = {\n data,\n context: this.context,\n };\n return (0, SchemaProcessor_1.processSchema)({ schema: internalSchema });\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n this.data.authorization = Array.isArray(rules) ? rules : [rules];\n const { authorization: _, ...rest } = this;\n return rest;\n },\n addToSchema(types) {\n validateAddToSchema(types);\n this.data.types = { ...this.data.types, ...types };\n const { addToSchema: _, ...rest } = this;\n return rest;\n },\n addQueries(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addQueries: _, ...rest } = this;\n return rest;\n },\n addMutations(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addMutations: _, ...rest } = this;\n return rest;\n },\n addSubscriptions(types) {\n this.data.types = { ...this.data.types, ...types };\n const { addSubscriptions: _, ...rest } = this;\n return rest;\n },\n setAuthorization(callback) {\n callback(models, this);\n const { setAuthorization: _, ...rest } = this;\n return rest;\n },\n setRelationships(callback) {\n const { setRelationships: _, ...rest } = this;\n // The relationships are added via `models.<Model>.relationships`\n // modifiers that's being called within the callback. They are modifying\n // by references on each model, so there is not anything else to be done\n // here.\n callback(models);\n return rest;\n },\n renameModels(callback) {\n const { renameModels: _, ...rest } = this;\n // returns an array of tuples [curName, newName]\n const changeLog = callback();\n changeLog.forEach(([curName, newName]) => {\n const currentType = data.types[curName];\n if (currentType === undefined) {\n throw new Error(`Invalid renameModels call. ${curName} is not defined in the schema`);\n }\n if (typeof newName !== 'string' || newName.length < 1) {\n throw new Error(`Invalid renameModels call. New name must be a non-empty string. Received: \"${newName}\"`);\n }\n models[newName] = currentType;\n data.types[newName] = currentType;\n models[newName].data.originalName = curName;\n delete models[curName];\n delete data.types[curName];\n });\n return rest;\n },\n ...exports.rdsSchemaBrand,\n };\n}\nfunction _ddbSchema(types, config) {\n const data = {\n types,\n authorization: [],\n configuration: config,\n };\n return {\n data,\n transform() {\n const internalSchema = {\n data,\n context: this.context,\n };\n return (0, SchemaProcessor_1.processSchema)({ schema: internalSchema });\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n this.data.authorization = Array.isArray(rules) ? rules : [rules];\n const { authorization: _, ...rest } = this;\n return rest;\n },\n models: filterSchemaModelTypes(data.types),\n ...ddbSchemaBrand,\n };\n}\nfunction bindConfigToSchema(config) {\n return (types) => {\n return (config.database.engine === 'dynamodb'\n ? _ddbSchema(types, config)\n : _rdsSchema(types, config));\n };\n}\n/**\n * The API and data model definition for Amplify Data. Pass in `{ <NAME>: a.model(...) }` to create a database table\n * and exposes CRUDL operations via an API.\n * @param types The API and data model definition\n * @returns An API and data model definition to be deployed with Amplify (Gen 2) experience (`processSchema(...)`)\n * or with the Amplify Data CDK construct (`@aws-amplify/data-construct`)\n */\nexports.schema = bindConfigToSchema({ database: { engine: 'dynamodb' } });\n/**\n * Configure wraps schema definition with non-default config to allow usecases other than\n * the default DynamoDB use-case.\n *\n * @param config The SchemaConfig augments the schema with content like the database type\n * @returns\n */\nfunction configure(config) {\n return {\n schema: bindConfigToSchema(config),\n };\n}\nfunction isCustomPathData(obj) {\n return ('stack' in obj &&\n (typeof obj.stack === 'undefined' || typeof obj.stack === 'string') &&\n 'entry' in obj &&\n typeof obj.entry === 'string');\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,kBAAkB,GAAG,MAAM;AAClI,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;AAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;AAC1C,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACtD,MAAM,eAAe,GAAG,OAAO,CAA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,SAAS,SAAS,CAAC,MAAM,EAAE;AAC3B,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;AAC1C,KAAK;AACL;AACA,SAAS,gBAAgB,CAAC,GAAG,EAAE;AAC/B,IAAI,QAAQ,OAAO,IAAI,GAAG;AAC1B,SAAS,OAAO,GAAG,CAAC,KAAK,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC;AAC3E,QAAQ,OAAO,IAAI,GAAG;AACtB,QAAQ,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;AACrC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelType.js","sources":["../../src/ModelType.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isSchemaModelType = void 0;\nexports.model = model;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst ModelIndex_1 = require(\"./ModelIndex\");\nconst brandName = 'modelType';\nfunction _model(fields) {\n const data = {\n fields,\n identifier: ['id'],\n secondaryIndexes: [],\n authorization: [],\n disabledOperations: [],\n };\n const builder = {\n identifier(identifier) {\n data.identifier = identifier;\n return this;\n },\n secondaryIndexes(callback) {\n data.secondaryIndexes = callback(ModelIndex_1.modelIndex);\n return this;\n },\n disableOperations(ops) {\n data.disabledOperations = ops;\n return this;\n },\n authorization(callback) {\n const { resource: _, ...rest } = Authorization_1.allow;\n const rules = callback(rest);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n ...(0, util_1.brand)(brandName),\n };\n return {\n ...builder,\n data,\n relationships(relationships) {\n data.fields = { ...data.fields, ...relationships };\n },\n fields: data.fields,\n };\n}\n/**\n * Model Type type guard\n * @param modelType - api-next ModelType\n * @returns true if the given value is a ModelSchema\n */\nconst isSchemaModelType = (modelType) => {\n const internalType = modelType;\n return (typeof internalType === 'object' &&\n internalType.data !== undefined &&\n internalType.data.fields !== undefined &&\n internalType.data.authorization !== undefined &&\n internalType.data.identifier !== undefined &&\n internalType.data.secondaryIndexes !== undefined &&\n typeof internalType.relationships === 'function');\n};\nexports.isSchemaModelType = isSchemaModelType;\n/**\n * A data model that creates a matching Amazon DynamoDB table and provides create, read (list and get), update,\n * delete, and subscription APIs.\n *\n * @param fields database table fields. Supports scalar types and relationship types.\n * @returns a data model definition\n */\nfunction model(fields) {\n return _model(fields);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,iBAAiB,GAAG,MAAM;AAClC,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAM,SAAS,GAAG,WAAW;AAC7B,SAAS,MAAM,CAAC,MAAM,EAAE;AACxB,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,MAAM;AACd,QAAQ,UAAU,EAAE,CAAC,IAAI,CAAC;AAC1B,QAAQ,gBAAgB,EAAE,EAAE;AAC5B,QAAQ,aAAa,EAAE,EAAE;AACzB,QAAQ,kBAAkB,EAAE,EAAE;AAC9B,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,UAAU,CAAC,UAAU,EAAE;AAC/B,YAAY,IAAI,CAAC,UAAU,GAAG,UAAU;AACxC,YAAY,OAAO,IAAI;AACvB,
|
|
1
|
+
{"version":3,"file":"ModelType.js","sources":["../../src/ModelType.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isSchemaModelType = void 0;\nexports.model = model;\nconst util_1 = require(\"./util\");\nconst Authorization_1 = require(\"./Authorization\");\nconst ModelIndex_1 = require(\"./ModelIndex\");\nconst brandName = 'modelType';\nfunction _model(fields) {\n const data = {\n fields,\n identifier: ['id'],\n secondaryIndexes: [],\n authorization: [],\n disabledOperations: [],\n };\n const builder = {\n identifier(identifier) {\n data.identifier = identifier;\n return this;\n },\n secondaryIndexes(callback) {\n data.secondaryIndexes = callback(ModelIndex_1.modelIndex);\n return this;\n },\n disableOperations(ops) {\n data.disabledOperations = ops;\n return this;\n },\n authorization(callback) {\n const { resource: _, ...rest } = Authorization_1.allow;\n const rules = callback(rest);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n ...(0, util_1.brand)(brandName),\n };\n return {\n ...builder,\n data,\n relationships(relationships) {\n data.fields = { ...data.fields, ...relationships };\n },\n fields: data.fields,\n };\n}\n/**\n * Model Type type guard\n * @param modelType - api-next ModelType\n * @returns true if the given value is a ModelSchema\n */\nconst isSchemaModelType = (modelType) => {\n const internalType = modelType;\n return (typeof internalType === 'object' &&\n internalType.data !== undefined &&\n internalType.data.fields !== undefined &&\n internalType.data.authorization !== undefined &&\n internalType.data.identifier !== undefined &&\n internalType.data.secondaryIndexes !== undefined &&\n typeof internalType.relationships === 'function');\n};\nexports.isSchemaModelType = isSchemaModelType;\n/**\n * A data model that creates a matching Amazon DynamoDB table and provides create, read (list and get), update,\n * delete, and subscription APIs.\n *\n * @param fields database table fields. Supports scalar types and relationship types.\n * @returns a data model definition\n */\nfunction model(fields) {\n return _model(fields);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,iBAAiB,GAAG,MAAM;AAClC,OAAO,CAAC,KAAK,GAAG,KAAK;AACrB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAChC,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAClD,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAM,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AM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,aAAa,EAAE;AAC9D,QAAQ,CAAC;AACT,QAAQ,MAAM,EAAE,IAAI,CAAC,MAAM;AAC3B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,iBAAiB,GAAG,CAAC,SAAS,KAAK;AACzC,IAAI,MAAM,YAAY,GAAG,SAAS;AAClC,IAAI,QAAQ,OAAO,YAAY,KAAK,QAAQ;AAC5C,QAAQ,YAAY,CAAC,IAAI,KAAK,SAAS;AACvC,QAAQ,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS;AAC9C,QAAQ,YAAY,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS;AACrD,QAAQ,YAAY,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS;AAClD,QAAQ,YAAY,CAAC,IAAI,CAAC,gBAAgB,KAAK,SAAS;AACxD,QAAQ,OAAO,YAAY,CAAC,aAAa,KAAK,UAAU;AACxD,CAAC;AACD,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,KAAK,CAAC,MAAM,EAAE;AACvB,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC;AACzB;;"}
|
package/dist/cjs/RefType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefType.js","sources":["../../src/RefType.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ref = ref;\nconst Authorization_1 = require(\"./Authorization\");\nconst ModelField_1 = require(\"./ModelField\");\nconst brandName = 'ref';\nfunction brandedBuilder(builder) {\n return builder;\n}\nfunction _ref(link) {\n const data = {\n type: 'ref',\n link,\n valueRequired: false,\n array: false,\n arrayRequired: false,\n mutationOperations: [],\n authorization: [],\n };\n const builder = brandedBuilder({\n required() {\n if (data.array) {\n data.arrayRequired = true;\n }\n else {\n data.valueRequired = true;\n }\n return this;\n },\n array() {\n data.array = true;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n mutations(operations) {\n data.mutationOperations = operations;\n return this;\n },\n });\n return { ...builder, data };\n}\nfunction ref(link) {\n return _ref(link);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAC7B,OAAO,CAAC,cAAc;AAE3C,SAAS,cAAc,CAAC,OAAO,EAAE;AACjC,IAAI,OAAO,OAAO;AAClB;AACA,SAAS,IAAI,CAAC,IAAI,EAAE;AACpB,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,IAAI,EAAE,KAAK;AACnB,QAAQ,IAAI;AACZ,QAAQ,aAAa,EAAE,KAAK;AAC5B,QAAQ,KAAK,EAAE,KAAK;AACpB,QAAQ,aAAa,EAAE,KAAK;AAC5B,QAAQ,kBAAkB,EAAE,EAAE;AAC9B,QAAQ,aAAa,EAAE,EAAE;AACzB,KAAK;AACL,IAAI,MAAM,OAAO,GAAG,cAAc,CAAC;AACnC,QAAQ,QAAQ,GAAG;AACnB,YAAY,IAAI,IAAI,CAAC,KAAK,EAAE;AAC5B,gBAAgB,IAAI,CAAC,aAAa,GAAG,IAAI;AACzC;
|
|
1
|
+
{"version":3,"file":"RefType.js","sources":["../../src/RefType.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ref = ref;\nconst Authorization_1 = require(\"./Authorization\");\nconst ModelField_1 = require(\"./ModelField\");\nconst brandName = 'ref';\nfunction brandedBuilder(builder) {\n return builder;\n}\nfunction _ref(link) {\n const data = {\n type: 'ref',\n link,\n valueRequired: false,\n array: false,\n arrayRequired: false,\n mutationOperations: [],\n authorization: [],\n };\n const builder = brandedBuilder({\n required() {\n if (data.array) {\n data.arrayRequired = true;\n }\n else {\n data.valueRequired = true;\n }\n return this;\n },\n array() {\n data.array = true;\n return this;\n },\n authorization(callback) {\n const rules = callback(Authorization_1.allow);\n data.authorization = Array.isArray(rules) ? rules : [rules];\n return this;\n },\n mutations(operations) {\n data.mutationOperations = operations;\n return this;\n },\n });\n return { ...builder, data };\n}\nfunction ref(link) {\n return _ref(link);\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAC7B,OAAO,CAAC,cAAc;AAE3C,SAAS,cAAc,CAAC,OAAO,EAAE;AACjC,IAAI,OAAO,OAAO;AAClB;AACA,SAAS,IAAI,CAAC,IAAI,EAAE;AACpB,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,IAAI,EAAE,KAAK;AACnB,QAAQ,IAAI;AACZ,QAAQ,aAAa,EAAE,KAAK;AAC5B,QAAQ,KAAK,EAAE,KAAK;AACpB,QAAQ,aAAa,EAAE,KAAK;AAC5B,QAAQ,kBAAkB,EAAE,EAAE;AAC9B,QAAQ,aAAa,EAAE,EAAE;AACzB,KAAK;AACL,IAAI,MAAM,OAAO,GAAG,cAAc,CAAC;AACnC,QAAQ,QAAQ,GAAG;AACnB,YAAY,IAAI,IAAI,CAAC,KAAK,EAAE;AAC5B,gBAAgB,IAAI,CAAC,aAAa,GAAG,IAAI;AACzC,YAAY;AACZ,iBAAiB;AACjB,gBAAgB,IAAI,CAAC,aAAa,GAAG,IAAI;AACzC,YAAY;AACZ,YAAY,OAAO,IAAI;AACvB,QAAQ,CAAC;AACT,QAAQ,KAAK,GAAG;AAChB,YAAY,IAAI,CAAC,KAAK,GAAG,IAAI;AAC7B,YAAY,OA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