@warp-drive/utilities 5.6.0-alpha.11
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/CHANGELOG.md +1 -0
- package/LICENSE.md +23 -0
- package/README.md +54 -0
- package/addon-main.cjs +5 -0
- package/declarations/-private/active-record/find-record.d.ts +66 -0
- package/declarations/-private/active-record/find-record.d.ts.map +1 -0
- package/declarations/-private/active-record/query.d.ts +54 -0
- package/declarations/-private/active-record/query.d.ts.map +1 -0
- package/declarations/-private/active-record/save-record.d.ts +144 -0
- package/declarations/-private/active-record/save-record.d.ts.map +1 -0
- package/declarations/-private/builder-utils.d.ts +5 -0
- package/declarations/-private/builder-utils.d.ts.map +1 -0
- package/declarations/-private/handlers/auto-compress.d.ts +153 -0
- package/declarations/-private/handlers/auto-compress.d.ts.map +1 -0
- package/declarations/-private/json-api/-utils.d.ts +110 -0
- package/declarations/-private/json-api/-utils.d.ts.map +1 -0
- package/declarations/-private/json-api/find-record.d.ts +66 -0
- package/declarations/-private/json-api/find-record.d.ts.map +1 -0
- package/declarations/-private/json-api/find-record.type-test.d.ts +2 -0
- package/declarations/-private/json-api/find-record.type-test.d.ts.map +1 -0
- package/declarations/-private/json-api/query.d.ts +104 -0
- package/declarations/-private/json-api/query.d.ts.map +1 -0
- package/declarations/-private/json-api/query.type-test.d.ts +2 -0
- package/declarations/-private/json-api/query.type-test.d.ts.map +1 -0
- package/declarations/-private/json-api/save-record.d.ts +191 -0
- package/declarations/-private/json-api/save-record.d.ts.map +1 -0
- package/declarations/-private/json-api/serialize.d.ts +57 -0
- package/declarations/-private/json-api/serialize.d.ts.map +1 -0
- package/declarations/-private/rest/find-record.d.ts +66 -0
- package/declarations/-private/rest/find-record.d.ts.map +1 -0
- package/declarations/-private/rest/query.d.ts +54 -0
- package/declarations/-private/rest/query.d.ts.map +1 -0
- package/declarations/-private/rest/save-record.d.ts +144 -0
- package/declarations/-private/rest/save-record.d.ts.map +1 -0
- package/declarations/-private/string/inflect.d.ts +105 -0
- package/declarations/-private/string/inflect.d.ts.map +1 -0
- package/declarations/-private/string/inflections.d.ts +10 -0
- package/declarations/-private/string/inflections.d.ts.map +1 -0
- package/declarations/-private/string/transform.d.ts +89 -0
- package/declarations/-private/string/transform.d.ts.map +1 -0
- package/declarations/-private.d.ts +2 -0
- package/declarations/-private.d.ts.map +1 -0
- package/declarations/active-record.d.ts +71 -0
- package/declarations/active-record.d.ts.map +1 -0
- package/declarations/handlers.d.ts +8 -0
- package/declarations/handlers.d.ts.map +1 -0
- package/declarations/index.d.ts +255 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/json-api.d.ts +51 -0
- package/declarations/json-api.d.ts.map +1 -0
- package/declarations/rest.d.ts +51 -0
- package/declarations/rest.d.ts.map +1 -0
- package/declarations/string.d.ts +14 -0
- package/declarations/string.d.ts.map +1 -0
- package/dist/-private.js +7 -0
- package/dist/-private.js.map +1 -0
- package/dist/active-record.js +393 -0
- package/dist/active-record.js.map +1 -0
- package/dist/builder-utils-Donkk-BZ.js +22 -0
- package/dist/builder-utils-Donkk-BZ.js.map +1 -0
- package/dist/handlers.js +141 -0
- package/dist/handlers.js.map +1 -0
- package/dist/index.js +403 -0
- package/dist/index.js.map +1 -0
- package/dist/inflect-C1laviCe.js +376 -0
- package/dist/inflect-C1laviCe.js.map +1 -0
- package/dist/json-api.js +671 -0
- package/dist/json-api.js.map +1 -0
- package/dist/rest.js +393 -0
- package/dist/rest.js.map +1 -0
- package/dist/string.js +1 -0
- package/dist/string.js.map +1 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/ember-data-logo-dark.svg +12 -0
- package/logos/ember-data-logo-light.svg +12 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-api.js","sources":["../src/-private/json-api/-utils.ts","../src/-private/json-api/find-record.ts","../src/-private/json-api/query.ts","../src/-private/json-api/save-record.ts","../src/-private/json-api/serialize.ts"],"sourcesContent":["import type { QueryParamsSource } from '@warp-drive/core/types/params';\n\nimport type { BuildURLConfig } from '../../index.ts';\nimport { buildQueryParams as buildParams, setBuildURLConfig as setConfig } from '../../index.ts';\n\nexport interface JSONAPIConfig extends BuildURLConfig {\n profiles?: {\n pagination?: string;\n [key: string]: string | undefined;\n };\n extensions?: {\n atomic?: string;\n [key: string]: string | undefined;\n };\n}\n\nconst JsonApiAccept = 'application/vnd.api+json';\nconst DEFAULT_CONFIG: JSONAPIConfig = { host: '', namespace: '' };\nexport let CONFIG: JSONAPIConfig = DEFAULT_CONFIG;\nexport let ACCEPT_HEADER_VALUE = 'application/vnd.api+json';\n\n/**\n * Allows setting extensions and profiles to be used in the `Accept` header.\n *\n * Extensions and profiles are keyed by their namespace with the value being\n * their URI.\n *\n * Example:\n *\n * ```ts\n * setBuildURLConfig({\n * extensions: {\n * atomic: 'https://jsonapi.org/ext/atomic'\n * },\n * profiles: {\n * pagination: 'https://jsonapi.org/profiles/ethanresnick/cursor-pagination'\n * }\n * });\n * ```\n *\n * This also sets the global configuration for `buildBaseURL`\n * for host and namespace values for the global coniguration\n * done via `import { setBuildURLConfig } from '@warp-drive/utilities';`\n *\n * These values may still be overridden by passing\n * them to buildBaseURL directly.\n *\n * This method may be called as many times as needed\n *\n * ```ts\n * type BuildURLConfig = {\n * host: string;\n * namespace: string'\n * }\n * ```\n *\n * @public\n * @param {BuildURLConfig} config\n * @return {void}\n */\nexport function setBuildURLConfig(config: JSONAPIConfig): void {\n CONFIG = Object.assign({}, DEFAULT_CONFIG, config);\n\n if (config.profiles || config.extensions) {\n let accept = JsonApiAccept;\n if (config.profiles) {\n const profiles = Object.values(config.profiles);\n if (profiles.length) {\n accept += ';profile=\"' + profiles.join(' ') + '\"';\n }\n }\n if (config.extensions) {\n const extensions = Object.values(config.extensions);\n if (extensions.length) {\n accept += ';ext=' + extensions.join(' ');\n }\n }\n ACCEPT_HEADER_VALUE = accept;\n }\n\n setConfig(config);\n}\n\ninterface RelatedObject {\n [key: string]: string | string[] | RelatedObject;\n}\n\nexport type JsonApiQuery = {\n include?: string | string[] | RelatedObject;\n fields?: Record<string, string | string[]>;\n page?: {\n size?: number;\n after?: string;\n before?: string;\n };\n};\n\nfunction isJsonApiQuery(query: JsonApiQuery | QueryParamsSource): query is JsonApiQuery {\n if ('include' in query && query.include && typeof query.include === 'object') {\n return true;\n }\n if ('fields' in query || 'page' in query) {\n return true;\n }\n return false;\n}\n\nfunction collapseIncludePaths(basePath: string, include: RelatedObject, paths: string[]) {\n const keys = Object.keys(include);\n for (let i = 0; i < keys.length; i++) {\n // the key is always included too\n paths.push(`${basePath}.${keys[i]}`);\n const key = keys[i];\n const value = include[key];\n\n // include: { 'company': 'field1,field2' }\n if (typeof value === 'string') {\n value.split(',').forEach((field) => {\n paths.push(`${basePath}.${key}.${field}`);\n });\n\n // include: { 'company': ['field1', 'field2'] }\n } else if (Array.isArray(value)) {\n value.forEach((field) => {\n paths.push(`${basePath}.${key}.${field}`);\n });\n\n // include: { 'company': { 'nested': 'field1,field2' } }\n } else {\n collapseIncludePaths(`${basePath}.${key}`, value, paths);\n }\n }\n}\n\n/**\n * Sorts query params by both key and value, returning a query params string\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n * - If `included` is an object we build paths dynamically for you\n * Treats `fields` specially, building JSON:API partial fields params from an object\n * Treats `page` specially, building cursor-pagination profile page params from an object\n *\n * ```ts\n * const params = buildQueryParams({\n * include: {\n * company: {\n * locations: 'address'\n * }\n * },\n * fields: {\n * company: ['name', 'ticker'],\n * person: 'name'\n * },\n * page: {\n * size: 10,\n * after: 'abc',\n * }\n * });\n *\n * // => 'fields[company]=name,ticker&fields[person]=name&include=company.locations,company.locations.address&page[after]=abc&page[size]=10'\n * ```\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`\n *\n * @public\n * @param {URLSearchParams | Object} params\n * @param {Object} [options]\n * @return {String} A sorted query params string without the leading `?`\n */\nexport function buildQueryParams(query: JsonApiQuery | QueryParamsSource): string {\n if (query instanceof URLSearchParams) {\n return buildParams(query);\n }\n\n if (!isJsonApiQuery(query)) {\n return buildParams(query);\n }\n\n const { include, fields, page, ...rest } = query;\n const finalQuery: QueryParamsSource = {\n ...rest,\n };\n\n if ('include' in query) {\n // include: { 'company': 'field1,field2' }\n // include: { 'company': ['field1', 'field2'] }\n // include: { 'company': { 'nested': 'field1,field2' } }\n // include: { 'company': { 'nested': ['field1', 'field2'] } }\n if (include && !Array.isArray(include) && typeof include === 'object') {\n const includePaths: string[] = [];\n collapseIncludePaths('', include, includePaths);\n finalQuery.include = includePaths.sort();\n\n // include: 'field1,field2'\n // include: ['field1', 'field2']\n } else {\n finalQuery.include = include as string;\n }\n }\n\n if (fields) {\n const keys = Object.keys(fields).sort();\n for (let i = 0; i < keys.length; i++) {\n const resourceType = keys[i];\n const value = fields[resourceType];\n\n // fields: { 'company': ['field1', 'field2'] }\n if (Array.isArray(value)) {\n finalQuery[`fields[${resourceType}]`] = value.sort().join(',');\n\n // fields: { 'company': 'field1' }\n // fields: { 'company': 'field1,field2' }\n } else {\n finalQuery[`fields[${resourceType}]`] = value.split(',').sort().join(',');\n }\n }\n }\n\n if (page) {\n const keys = Object.keys(page).sort() as Array<'size' | 'after' | 'before'>;\n keys.forEach((key) => {\n const value = page[key];\n finalQuery[`page[${key}]`] = value!;\n });\n }\n\n return buildParams(finalQuery);\n}\n","import type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive/core/types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive/core/types/spec/document';\n\nimport { buildBaseURL, buildQueryParams, type FindRecordUrlOptions } from '../../index.ts';\nimport { pluralize } from '../../string.ts';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\nimport { ACCEPT_HEADER_VALUE } from './-utils.ts';\n\n/**\n * Builds request options to fetch a single resource by a known id or identifier\n * configured for the url and header expectations of most JSON:API APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/json-api';\n *\n * const data = await store.request(findRecord('person', '1'));\n * ```\n *\n * **With Options**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/json-api';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **With an Identifier**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/json-api';\n *\n * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/json-api';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param options\n */\n\nexport type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, 'data'> & { data: T };\n\nexport function findRecord<T>(\n identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;\nexport function findRecord(\n identifier: RemotelyAccessibleIdentifier,\n options?: FindRecordOptions\n): FindRecordRequestOptions;\nexport function findRecord<T>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;\nexport function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;\nexport function findRecord(\n arg1: string | RemotelyAccessibleIdentifier,\n arg2: string | FindRecordOptions | undefined,\n arg3?: FindRecordOptions\n): FindRecordRequestOptions {\n const identifier: RemotelyAccessibleIdentifier = typeof arg1 === 'string' ? { type: arg1, id: arg2 as string } : arg1;\n const options = ((typeof arg1 === 'string' ? arg3 : arg2) || {}) as FindRecordOptions;\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: FindRecordUrlOptions = {\n identifier,\n op: 'findRecord',\n resourcePath: pluralize(identifier.type),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', ACCEPT_HEADER_VALUE);\n\n return {\n url: options.include?.length\n ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}`\n : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'findRecord',\n records: [identifier],\n };\n}\n","import type { QueryParamsSource } from '@warp-drive/core/types/params';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type {\n CacheOptions,\n ConstrainedRequestOptions,\n PostQueryRequestOptions,\n QueryRequestOptions,\n} from '@warp-drive/core/types/request';\nimport type { CollectionResourceDataDocument } from '@warp-drive/core/types/spec/document';\n\nimport { buildBaseURL, buildQueryParams, type QueryUrlOptions } from '../../index.ts';\nimport { pluralize } from '../../string.ts';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\nimport { ACCEPT_HEADER_VALUE } from './-utils.ts';\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most JSON:API APIs.\n *\n * The key difference between this and `postQuery` is that this method will send the query\n * as query params in the url of a \"GET\" request instead of as the JSON body of a \"POST\"\n * request.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/json-api';\n *\n * const data = await store.request(query('person'));\n * ```\n *\n * **With Query Params**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/json-api';\n *\n * const options = query('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/json-api';\n *\n * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param query\n * @param options\n */\nexport function query<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource<T>,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;\nexport function query(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions;\nexport function query(\n type: string,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): QueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: pluralize(type),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', ACCEPT_HEADER_VALUE);\n const queryString = buildQueryParams(query, options.urlParamsSettings);\n\n return {\n url: queryString ? `${url}?${queryString}` : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'query',\n };\n}\n\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most JSON:API APIs.\n *\n * The key difference between this and `query` is that this method will send the query\n * as the JSON body of a \"POST\" request instead of as query params in the url of a \"GET\"\n * request.\n *\n * A CacheKey is generated from the url and query params, and used to cache the response\n * in the store.\n *\n * ```ts\n * import { postQuery } from '@warp-drive/utilities/json-api';\n *\n * const options = postQuery('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { postQuery } from '@warp-drive/utilities/json-api';\n *\n * const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param query\n * @param options\n */\nexport function postQuery<T>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): PostQueryRequestOptions<CollectionResourceDataDocument<T>, T>;\nexport function postQuery(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): PostQueryRequestOptions;\nexport function postQuery(\n type: string,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): PostQueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: options.resourcePath ?? pluralize(type),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', ACCEPT_HEADER_VALUE);\n\n const queryData = structuredClone(query);\n cacheOptions.key = cacheOptions.key ?? `${url}?${buildQueryParams(queryData, options.urlParamsSettings)}`;\n\n return {\n url,\n method: 'POST',\n body: JSON.stringify(query),\n headers,\n cacheOptions: cacheOptions as CacheOptions & { key: string },\n op: 'query',\n };\n}\n","import { recordIdentifierFor } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@warp-drive/core/types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive/core/types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive/core/types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive/core/types/spec/document';\n\nimport {\n buildBaseURL,\n type CreateRecordUrlOptions,\n type DeleteRecordUrlOptions,\n type UpdateRecordUrlOptions,\n} from '../../index.ts';\nimport { pluralize } from '../../string.ts';\nimport { copyForwardUrlOptions } from '../builder-utils.ts';\nimport { ACCEPT_HEADER_VALUE } from './-utils.ts';\n\nfunction isExisting(identifier: StableRecordIdentifier): identifier is StableExistingRecordIdentifier {\n return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;\n}\n\n/**\n * Builds request options to delete record for resources,\n * configured for the url, method and header expectations of most JSON:API APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const data = await store.request(deleteRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const options = deleteRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;\nexport function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;\nexport function deleteRecord(record: unknown, options: ConstrainedRequestOptions = {}): DeleteRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot delete a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: DeleteRecordUrlOptions = {\n identifier: identifier,\n op: 'deleteRecord',\n resourcePath: pluralize(identifier.type),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', ACCEPT_HEADER_VALUE);\n\n return {\n url,\n method: 'DELETE',\n headers,\n op: 'deleteRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to create new record for resources,\n * configured for the url, method and header expectations of most JSON:API APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const data = await store.request(createRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const options = createRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;\nexport function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;\nexport function createRecord(record: unknown, options: ConstrainedRequestOptions = {}): CreateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n\n const urlOptions: CreateRecordUrlOptions = {\n identifier: identifier,\n op: 'createRecord',\n resourcePath: pluralize(identifier.type),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', ACCEPT_HEADER_VALUE);\n\n return {\n url,\n method: 'POST',\n headers,\n op: 'createRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url, method and header expectations of most JSON:API APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(updateRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = updateRecord(person, { patch: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(\n record: T,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;\nexport function updateRecord(\n record: unknown,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions;\nexport function updateRecord(\n record: unknown,\n options: ConstrainedRequestOptions & { patch?: boolean } = {}\n): UpdateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot update a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: UpdateRecordUrlOptions = {\n identifier: identifier,\n op: 'updateRecord',\n resourcePath: pluralize(identifier.type),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', ACCEPT_HEADER_VALUE);\n\n return {\n url,\n method: options.patch ? 'PATCH' : 'PUT',\n headers,\n op: 'updateRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url and header expectations of most JSON:API APIs\n * for a PATCH request.\n *\n * Note: This is a convenience method that calls `updateRecord` with the\n * supplied request with the `patch` option set to `true`.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { patchRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(patchRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { patchRecord } from '@warp-drive/utilities/json-api';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = patchRecord(person);\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function patchRecord<T>(record: T, options?: ConstrainedRequestOptions): UpdateRequestOptions<T>;\nexport function patchRecord(record: unknown, options?: ConstrainedRequestOptions): UpdateRequestOptions;\nexport function patchRecord(record: unknown, options: ConstrainedRequestOptions = {}): UpdateRequestOptions {\n const opts = options as ConstrainedRequestOptions & { patch: true };\n opts.patch = true;\n return updateRecord(record, opts);\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { Relationship } from '@warp-drive/core/types/cache/relationship';\nimport type { StableRecordIdentifier } from '@warp-drive/core/types/identifier';\nimport type { Value } from '@warp-drive/core/types/json/raw';\nimport type { InnerRelationshipDocument, ResourceObject } from '@warp-drive/core/types/spec/json-api-raw';\n\ntype ChangedRelationshipData = InnerRelationshipDocument;\n\nexport type JsonApiResourcePatch =\n | {\n type: string;\n id: string;\n attributes?: Record<string, Value>;\n relationships?: Record<string, ChangedRelationshipData>;\n }\n | {\n type: string;\n id: null;\n lid: string;\n attributes?: Record<string, Value>;\n relationships?: Record<string, ChangedRelationshipData>;\n };\n\n/**\n * Serializes the current state of a resource or array of resources for use with POST or PUT requests.\n *\n * @public\n * @param {Cache} cache}\n * @param {StableRecordIdentifier} identifier\n * @return {Object} An object with a `data` property containing the serialized resource patch\n */\nexport function serializeResources(cache: Cache, identifiers: StableRecordIdentifier): { data: ResourceObject };\nexport function serializeResources(cache: Cache, identifiers: StableRecordIdentifier[]): { data: ResourceObject[] };\nexport function serializeResources(\n cache: Cache,\n identifiers: StableRecordIdentifier | StableRecordIdentifier[]\n): { data: ResourceObject | ResourceObject[] } {\n return {\n data: Array.isArray(identifiers)\n ? identifiers.map((identifier) => _serializeResource(cache, identifier))\n : _serializeResource(cache, identifiers),\n };\n}\n\ntype SerializedRef =\n | {\n id: string;\n type: string;\n }\n | { id: null; lid: string; type: string };\n\nfunction fixRef({\n id,\n lid,\n type,\n}: { id: string; lid?: string; type: string } | { id: null; lid: string; type: string }): SerializedRef {\n if (id !== null) {\n return { id, type };\n }\n return { id, lid, type };\n}\n\nfunction fixRelData(\n rel: Relationship['data'] | InnerRelationshipDocument['data']\n): SerializedRef | SerializedRef[] | null {\n if (Array.isArray(rel)) {\n return rel.map((ref) => fixRef(ref));\n } else if (typeof rel === 'object' && rel !== null) {\n return fixRef(rel);\n }\n return null;\n}\n\nfunction _serializeResource(cache: Cache, identifier: StableRecordIdentifier): ResourceObject {\n const { id, lid, type } = identifier;\n // peek gives us everything we want, but since its referentially the same data\n // as is in the cache we clone it to avoid any accidental mutations\n const record = structuredClone(cache.peek(identifier)) as ResourceObject;\n assert(\n `A record with id ${String(id)} and type ${type} for lid ${lid} was not found not in the supplied Cache.`,\n record\n );\n\n // remove lid from anything that has an ID and slice any relationship arrays\n if (record.id !== null) {\n delete record.lid;\n }\n\n if (record.relationships) {\n for (const key of Object.keys(record.relationships)) {\n const relationship = record.relationships[key];\n relationship.data = fixRelData(relationship.data);\n if (Array.isArray(relationship.data)) {\n relationship.data = relationship.data.map((ref) => fixRef(ref));\n } else if (typeof relationship.data === 'object' && relationship.data !== null) {\n relationship.data = fixRef(relationship.data);\n }\n }\n }\n\n return record;\n}\n\n/**\n * Serializes changes to a resource for use with PATCH requests.\n *\n * Only attributes which are changed are serialized.\n * Only relationships which are changed are serialized.\n *\n * Collection relationships serialize the collection as a whole.\n *\n * If you would like to serialize updates to a collection more granularly\n * (for instance, as operations) request the diff from the store and\n * serialize as desired:\n *\n * ```ts\n * const relationshipDiffMap = cache.changedRelationships(identifier);\n * ```\n *\n * @public\n * @param {Cache} cache}\n * @param {StableRecordIdentifier} identifier\n * @return {Object} An object with a `data` property containing the serialized resource patch\n */\nexport function serializePatch(\n cache: Cache,\n identifier: StableRecordIdentifier\n // options: { include?: string[] } = {}\n): { data: JsonApiResourcePatch } {\n const { id, lid, type } = identifier;\n assert(\n `A record with id ${String(id)} and type ${type} for lid ${lid} was not found not in the supplied Cache.`,\n cache.peek(identifier)\n );\n\n const data: JsonApiResourcePatch =\n id === null\n ? { type, lid, id }\n : {\n type,\n id,\n };\n\n if (cache.hasChangedAttrs(identifier)) {\n const attrsChanges = cache.changedAttrs(identifier);\n const attributes: ResourceObject['attributes'] = {};\n\n Object.keys(attrsChanges).forEach((key) => {\n const change = attrsChanges[key];\n const newVal = change[1];\n attributes[key] = newVal === undefined ? null : structuredClone(newVal);\n });\n\n data.attributes = attributes;\n }\n\n const changedRelationships = cache.changedRelationships(identifier);\n if (changedRelationships.size) {\n const relationships: Record<string, ChangedRelationshipData> = {};\n changedRelationships.forEach((diff, key) => {\n relationships[key] = { data: fixRelData(diff.localState) } as ChangedRelationshipData;\n });\n\n data.relationships = relationships;\n }\n\n return { data };\n}\n"],"names":["JsonApiAccept","DEFAULT_CONFIG","host","namespace","ACCEPT_HEADER_VALUE","setBuildURLConfig","config","Object","assign","profiles","extensions","accept","values","length","join","setConfig","findRecord","arg1","arg2","arg3","identifier","type","id","options","cacheOptions","extractCacheOptions","urlOptions","op","resourcePath","pluralize","copyForwardUrlOptions","url","buildBaseURL","headers","Headers","append","include","buildQueryParams","urlParamsSettings","method","records","query","queryString","postQuery","queryData","structuredClone","key","body","JSON","stringify","isExisting","deleteRecord","record","recordIdentifierFor","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","data","createRecord","updateRecord","patch","serializeResources","cache","identifiers","Array","isArray","map","_serializeResource","fixRef","lid","fixRelData","rel","ref","peek","String","relationships","keys","relationship","serializePatch","hasChangedAttrs","attrsChanges","changedAttrs","attributes","forEach","change","newVal","undefined","changedRelationships","size","diff","local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4C,KAAK,CAACiB,eAAe,CAAC/D,UAAU,CAAC,EAAE;AACrC,IAAA,MAAMgE,YAAY,GAAGlB,KAAK,CAACmB,YAAY,CAACjE,UAAU,CAAC;IACnD,MAAMkE,UAAwC,GAAG,EAAE;IAEnD/E,MAAM,CAACyE,IAAI,CAACI,YAAY,CAAC,CAACG,OAAO,CAAEzC,GAAG,IAAK;AACzC,MAAA,MAAM0C,MAAM,GAAGJ,YAAY,CAACtC,GAAG,CAAC;AAChC,MAAA,MAAM2C,MAAM,GAAGD,MAAM,CAAC,CAAC,CAAC;AACxBF,MAAAA,UAAU,CAACxC,GAAG,CAAC,GAAG2C,MAAM,KAAKC,SAAS,GAAG,IAAI,GAAG7C,eAAe,CAAC4C,MAAM,CAAC;AACzE,KAAC,CAAC;IAEF5B,IAAI,CAACyB,UAAU,GAAGA,UAAU;AAC9B;AAEA,EAAA,MAAMK,oBAAoB,GAAGzB,KAAK,CAACyB,oBAAoB,CAACvE,UAAU,CAAC;EACnE,IAAIuE,oBAAoB,CAACC,IAAI,EAAE;IAC7B,MAAMb,aAAsD,GAAG,EAAE;AACjEY,IAAAA,oBAAoB,CAACJ,OAAO,CAAC,CAACM,IAAI,EAAE/C,GAAG,KAAK;MAC1CiC,aAAa,CAACjC,GAAG,CAAC,GAAG;AAAEe,QAAAA,IAAI,EAAEa,UAAU,CAACmB,IAAI,CAACC,UAAU;OAA8B;AACvF,KAAC,CAAC;IAEFjC,IAAI,CAACkB,aAAa,GAAGA,aAAa;AACpC;EAEA,OAAO;AAAElB,IAAAA;GAAM;AACjB;;;;"}
|
package/dist/rest.js
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { buildBaseURL, buildQueryParams } from "./index.js";
|
|
2
|
+
import { p as pluralize, g as camelize } from "./inflect-C1laviCe.js";
|
|
3
|
+
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
|
+
import { recordIdentifierFor } from '@warp-drive/core';
|
|
5
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Builds request options to fetch a single resource by a known id or identifier
|
|
9
|
+
* configured for the url and header expectations of most REST APIs.
|
|
10
|
+
*
|
|
11
|
+
* **Basic Usage**
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
15
|
+
*
|
|
16
|
+
* const data = await store.request(findRecord('person', '1'));
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* **With Options**
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
23
|
+
*
|
|
24
|
+
* const options = findRecord('person', '1', { include: ['pets', 'friends'] });
|
|
25
|
+
* const data = await store.request(options);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* **With an Identifier**
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
32
|
+
*
|
|
33
|
+
* const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
|
|
34
|
+
* const data = await store.request(options);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
38
|
+
*
|
|
39
|
+
* The following options are supported:
|
|
40
|
+
*
|
|
41
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
42
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
43
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type
|
|
44
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
45
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
46
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
47
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
48
|
+
* defaulting to `false` if none is configured.
|
|
49
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
53
|
+
*
|
|
54
|
+
* const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
|
|
55
|
+
* const data = await store.request(options);
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @param identifier
|
|
60
|
+
* @param options
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
function findRecord(arg1, arg2, arg3) {
|
|
64
|
+
const identifier = typeof arg1 === 'string' ? {
|
|
65
|
+
type: arg1,
|
|
66
|
+
id: arg2
|
|
67
|
+
} : arg1;
|
|
68
|
+
const options = (typeof arg1 === 'string' ? arg3 : arg2) || {};
|
|
69
|
+
const cacheOptions = extractCacheOptions(options);
|
|
70
|
+
const urlOptions = {
|
|
71
|
+
identifier,
|
|
72
|
+
op: 'findRecord',
|
|
73
|
+
resourcePath: pluralize(camelize(identifier.type))
|
|
74
|
+
};
|
|
75
|
+
copyForwardUrlOptions(urlOptions, options);
|
|
76
|
+
const url = buildBaseURL(urlOptions);
|
|
77
|
+
const headers = new Headers();
|
|
78
|
+
headers.append('Accept', 'application/json;charset=utf-8');
|
|
79
|
+
return {
|
|
80
|
+
url: options.include?.length ? `${url}?${buildQueryParams({
|
|
81
|
+
include: options.include
|
|
82
|
+
}, options.urlParamsSettings)}` : url,
|
|
83
|
+
method: 'GET',
|
|
84
|
+
headers,
|
|
85
|
+
cacheOptions,
|
|
86
|
+
op: 'findRecord',
|
|
87
|
+
records: [identifier]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Builds request options to query for resources, usually by a primary
|
|
93
|
+
* type, configured for the url and header expectations of most REST APIs.
|
|
94
|
+
*
|
|
95
|
+
* **Basic Usage**
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* import { query } from '@warp-drive/utilities/rest';
|
|
99
|
+
*
|
|
100
|
+
* const data = await store.request(query('person'));
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* **With Query Params**
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { query } from '@warp-drive/utilities/rest';
|
|
107
|
+
*
|
|
108
|
+
* const options = query('person', { include: ['pets', 'friends'] });
|
|
109
|
+
* const data = await store.request(options);
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
113
|
+
*
|
|
114
|
+
* The following options are supported:
|
|
115
|
+
*
|
|
116
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
117
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
118
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type
|
|
119
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
120
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
121
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
122
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
123
|
+
* defaulting to `false` if none is configured.
|
|
124
|
+
* - `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { query } from '@warp-drive/utilities/rest';
|
|
128
|
+
*
|
|
129
|
+
* const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
|
|
130
|
+
* const data = await store.request(options);
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
* @param identifier
|
|
135
|
+
* @param query
|
|
136
|
+
* @param options
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
function query(type,
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
141
|
+
query = {}, options = {}) {
|
|
142
|
+
const cacheOptions = extractCacheOptions(options);
|
|
143
|
+
const urlOptions = {
|
|
144
|
+
identifier: {
|
|
145
|
+
type
|
|
146
|
+
},
|
|
147
|
+
op: 'query',
|
|
148
|
+
resourcePath: pluralize(camelize(type))
|
|
149
|
+
};
|
|
150
|
+
copyForwardUrlOptions(urlOptions, options);
|
|
151
|
+
const url = buildBaseURL(urlOptions);
|
|
152
|
+
const headers = new Headers();
|
|
153
|
+
headers.append('Accept', 'application/json;charset=utf-8');
|
|
154
|
+
const queryString = buildQueryParams(query, options.urlParamsSettings);
|
|
155
|
+
return {
|
|
156
|
+
url: queryString ? `${url}?${queryString}` : url,
|
|
157
|
+
method: 'GET',
|
|
158
|
+
headers,
|
|
159
|
+
cacheOptions,
|
|
160
|
+
op: 'query'
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function isExisting(identifier) {
|
|
164
|
+
return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Builds request options to delete record for resources,
|
|
169
|
+
* configured for the url, method and header expectations of REST APIs.
|
|
170
|
+
*
|
|
171
|
+
* **Basic Usage**
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* import { deleteRecord } from '@warp-drive/utilities/rest';
|
|
175
|
+
*
|
|
176
|
+
* const person = store.peekRecord('person', '1');
|
|
177
|
+
*
|
|
178
|
+
* // mark record as deleted
|
|
179
|
+
* store.deleteRecord(person);
|
|
180
|
+
*
|
|
181
|
+
* // persist deletion
|
|
182
|
+
* const data = await store.request(deleteRecord(person));
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
186
|
+
*
|
|
187
|
+
* The following options are supported:
|
|
188
|
+
*
|
|
189
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
190
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
191
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
192
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
193
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
194
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
195
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
196
|
+
* defaulting to `false` if none is configured.
|
|
197
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
198
|
+
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* import { deleteRecord } from '@warp-drive/utilities/rest';
|
|
201
|
+
*
|
|
202
|
+
* const person = store.peekRecord('person', '1');
|
|
203
|
+
*
|
|
204
|
+
* // mark record as deleted
|
|
205
|
+
* store.deleteRecord(person);
|
|
206
|
+
*
|
|
207
|
+
* // persist deletion
|
|
208
|
+
* const options = deleteRecord(person, { namespace: 'api/v1' });
|
|
209
|
+
* const data = await store.request(options);
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @public
|
|
213
|
+
* @param record
|
|
214
|
+
* @param options
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
function deleteRecord(record, options = {}) {
|
|
218
|
+
const identifier = recordIdentifierFor(record);
|
|
219
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
220
|
+
if (!test) {
|
|
221
|
+
throw new Error(`Expected to be given a record instance`);
|
|
222
|
+
}
|
|
223
|
+
})(identifier) : {};
|
|
224
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
225
|
+
if (!test) {
|
|
226
|
+
throw new Error(`Cannot delete a record that does not have an associated type and id.`);
|
|
227
|
+
}
|
|
228
|
+
})(isExisting(identifier)) : {};
|
|
229
|
+
const urlOptions = {
|
|
230
|
+
identifier: identifier,
|
|
231
|
+
op: 'deleteRecord',
|
|
232
|
+
resourcePath: pluralize(camelize(identifier.type))
|
|
233
|
+
};
|
|
234
|
+
copyForwardUrlOptions(urlOptions, options);
|
|
235
|
+
const url = buildBaseURL(urlOptions);
|
|
236
|
+
const headers = new Headers();
|
|
237
|
+
headers.append('Accept', 'application/json;charset=utf-8');
|
|
238
|
+
return {
|
|
239
|
+
url,
|
|
240
|
+
method: 'DELETE',
|
|
241
|
+
headers,
|
|
242
|
+
op: 'deleteRecord',
|
|
243
|
+
data: {
|
|
244
|
+
record: identifier
|
|
245
|
+
},
|
|
246
|
+
records: [identifier]
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Builds request options to create new record for resources,
|
|
252
|
+
* configured for the url, method and header expectations of most REST APIs.
|
|
253
|
+
*
|
|
254
|
+
* **Basic Usage**
|
|
255
|
+
*
|
|
256
|
+
* ```ts
|
|
257
|
+
* import { createRecord } from '@warp-drive/utilities/rest';
|
|
258
|
+
*
|
|
259
|
+
* const person = store.createRecord('person', { name: 'Ted' });
|
|
260
|
+
* const data = await store.request(createRecord(person));
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
264
|
+
*
|
|
265
|
+
* The following options are supported:
|
|
266
|
+
*
|
|
267
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
268
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
269
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
270
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
271
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
272
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
273
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
274
|
+
* defaulting to `false` if none is configured.
|
|
275
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
276
|
+
*
|
|
277
|
+
* ```ts
|
|
278
|
+
* import { createRecord } from '@warp-drive/utilities/rest';
|
|
279
|
+
*
|
|
280
|
+
* const person = store.createRecord('person', { name: 'Ted' });
|
|
281
|
+
* const options = createRecord(person, { namespace: 'api/v1' });
|
|
282
|
+
* const data = await store.request(options);
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* @public
|
|
286
|
+
* @param record
|
|
287
|
+
* @param options
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
function createRecord(record, options = {}) {
|
|
291
|
+
const identifier = recordIdentifierFor(record);
|
|
292
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
293
|
+
if (!test) {
|
|
294
|
+
throw new Error(`Expected to be given a record instance`);
|
|
295
|
+
}
|
|
296
|
+
})(identifier) : {};
|
|
297
|
+
const urlOptions = {
|
|
298
|
+
identifier: identifier,
|
|
299
|
+
op: 'createRecord',
|
|
300
|
+
resourcePath: pluralize(camelize(identifier.type))
|
|
301
|
+
};
|
|
302
|
+
copyForwardUrlOptions(urlOptions, options);
|
|
303
|
+
const url = buildBaseURL(urlOptions);
|
|
304
|
+
const headers = new Headers();
|
|
305
|
+
headers.append('Accept', 'application/json;charset=utf-8');
|
|
306
|
+
return {
|
|
307
|
+
url,
|
|
308
|
+
method: 'POST',
|
|
309
|
+
headers,
|
|
310
|
+
op: 'createRecord',
|
|
311
|
+
data: {
|
|
312
|
+
record: identifier
|
|
313
|
+
},
|
|
314
|
+
records: [identifier]
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Builds request options to update existing record for resources,
|
|
320
|
+
* configured for the url, method and header expectations of most REST APIs.
|
|
321
|
+
*
|
|
322
|
+
* **Basic Usage**
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* import { updateRecord } from '@warp-drive/utilities/rest';
|
|
326
|
+
*
|
|
327
|
+
* const person = store.peekRecord('person', '1');
|
|
328
|
+
* person.name = 'Chris';
|
|
329
|
+
* const data = await store.request(updateRecord(person));
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
333
|
+
*
|
|
334
|
+
* The following options are supported:
|
|
335
|
+
*
|
|
336
|
+
* - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
|
|
337
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
338
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
339
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
340
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
341
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
342
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
343
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
344
|
+
* defaulting to `false` if none is configured.
|
|
345
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
346
|
+
*
|
|
347
|
+
* ```ts
|
|
348
|
+
* import { updateRecord } from '@warp-drive/utilities/rest';
|
|
349
|
+
*
|
|
350
|
+
* const person = store.peekRecord('person', '1');
|
|
351
|
+
* person.name = 'Chris';
|
|
352
|
+
* const options = updateRecord(person, { patch: true });
|
|
353
|
+
* const data = await store.request(options);
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* @public
|
|
357
|
+
* @param record
|
|
358
|
+
* @param options
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
function updateRecord(record, options = {}) {
|
|
362
|
+
const identifier = recordIdentifierFor(record);
|
|
363
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
364
|
+
if (!test) {
|
|
365
|
+
throw new Error(`Expected to be given a record instance`);
|
|
366
|
+
}
|
|
367
|
+
})(identifier) : {};
|
|
368
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
369
|
+
if (!test) {
|
|
370
|
+
throw new Error(`Cannot update a record that does not have an associated type and id.`);
|
|
371
|
+
}
|
|
372
|
+
})(isExisting(identifier)) : {};
|
|
373
|
+
const urlOptions = {
|
|
374
|
+
identifier: identifier,
|
|
375
|
+
op: 'updateRecord',
|
|
376
|
+
resourcePath: pluralize(camelize(identifier.type))
|
|
377
|
+
};
|
|
378
|
+
copyForwardUrlOptions(urlOptions, options);
|
|
379
|
+
const url = buildBaseURL(urlOptions);
|
|
380
|
+
const headers = new Headers();
|
|
381
|
+
headers.append('Accept', 'application/json;charset=utf-8');
|
|
382
|
+
return {
|
|
383
|
+
url,
|
|
384
|
+
method: options.patch ? 'PATCH' : 'PUT',
|
|
385
|
+
headers,
|
|
386
|
+
op: 'updateRecord',
|
|
387
|
+
data: {
|
|
388
|
+
record: identifier
|
|
389
|
+
},
|
|
390
|
+
records: [identifier]
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
export { createRecord, deleteRecord, findRecord, query, updateRecord };
|
package/dist/rest.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.js","sources":["../src/-private/rest/find-record.ts","../src/-private/rest/query.ts","../src/-private/rest/save-record.ts"],"sourcesContent":["import type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive/core/types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive/core/types/spec/document';\n\nimport { buildBaseURL, buildQueryParams, type FindRecordUrlOptions } from '../../index.ts';\nimport { camelize, pluralize } from '../../string';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\n\n/**\n * Builds request options to fetch a single resource by a known id or identifier\n * configured for the url and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/rest';\n *\n * const data = await store.request(findRecord('person', '1'));\n * ```\n *\n * **With Options**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/rest';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **With an Identifier**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/rest';\n *\n * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/rest';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param options\n */\nexport type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, 'data'> & { data: T };\n\nexport function findRecord<T>(\n identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;\nexport function findRecord(\n identifier: RemotelyAccessibleIdentifier,\n options?: FindRecordOptions\n): FindRecordRequestOptions;\nexport function findRecord<T>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;\nexport function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;\nexport function findRecord<T>(\n arg1: TypeFromInstance<T> | RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n arg2: string | FindRecordOptions | undefined,\n arg3?: FindRecordOptions\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T> {\n const identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>> =\n typeof arg1 === 'string' ? { type: arg1, id: arg2 as string } : arg1;\n const options: FindRecordOptions = (typeof arg1 === 'string' ? arg3 : (arg2 as FindRecordOptions)) || {};\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: FindRecordUrlOptions = {\n identifier,\n op: 'findRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url: options.include?.length\n ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}`\n : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'findRecord',\n records: [identifier],\n };\n}\n","import type { QueryParamsSource } from '@warp-drive/core/types/params';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive/core/types/request';\nimport type { CollectionResourceDataDocument } from '@warp-drive/core/types/spec/document';\n\nimport { buildBaseURL, buildQueryParams, type QueryUrlOptions } from '../../index.ts';\nimport { camelize, pluralize } from '../../string';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\n\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/rest';\n *\n * const data = await store.request(query('person'));\n * ```\n *\n * **With Query Params**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/rest';\n *\n * const options = query('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/rest';\n *\n * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param query\n * @param options\n */\nexport function query<T>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;\nexport function query(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions;\nexport function query(\n type: string,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): QueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: pluralize(camelize(type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n const queryString = buildQueryParams(query, options.urlParamsSettings);\n\n return {\n url: queryString ? `${url}?${queryString}` : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'query',\n };\n}\n","import { recordIdentifierFor } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@warp-drive/core/types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive/core/types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive/core/types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive/core/types/spec/document';\n\nimport {\n buildBaseURL,\n type CreateRecordUrlOptions,\n type DeleteRecordUrlOptions,\n type UpdateRecordUrlOptions,\n} from '../../index.ts';\nimport { camelize, pluralize } from '../../string';\nimport { copyForwardUrlOptions } from '../builder-utils.ts';\n\nfunction isExisting(identifier: StableRecordIdentifier): identifier is StableExistingRecordIdentifier {\n return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;\n}\n\n/**\n * Builds request options to delete record for resources,\n * configured for the url, method and header expectations of REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/rest';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const data = await store.request(deleteRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/rest';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const options = deleteRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;\nexport function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;\nexport function deleteRecord(record: unknown, options: ConstrainedRequestOptions = {}): DeleteRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot delete a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: DeleteRecordUrlOptions = {\n identifier: identifier,\n op: 'deleteRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'DELETE',\n headers,\n op: 'deleteRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to create new record for resources,\n * configured for the url, method and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/rest';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const data = await store.request(createRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/rest';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const options = createRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;\nexport function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;\nexport function createRecord(record: unknown, options: ConstrainedRequestOptions = {}): CreateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n\n const urlOptions: CreateRecordUrlOptions = {\n identifier: identifier,\n op: 'createRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'POST',\n headers,\n op: 'createRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url, method and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/rest';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(updateRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/rest';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = updateRecord(person, { patch: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(\n record: T,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;\nexport function updateRecord(\n record: unknown,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions;\nexport function updateRecord(\n record: unknown,\n options: ConstrainedRequestOptions & { patch?: boolean } = {}\n): UpdateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot update a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: UpdateRecordUrlOptions = {\n identifier: identifier,\n op: 'updateRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: options.patch ? 'PATCH' : 'PUT',\n headers,\n op: 'updateRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n"],"names":["findRecord","arg1","arg2","arg3","identifier","type","id","options","cacheOptions","extractCacheOptions","urlOptions","op","resourcePath","pluralize","camelize","copyForwardUrlOptions","url","buildBaseURL","headers","Headers","append","include","length","buildQueryParams","urlParamsSettings","method","records","query","queryString","isExisting","deleteRecord","record","recordIdentifierFor","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","data","createRecord","updateRecord","patch"],"mappings":";;;;;;AAYA;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;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBO,SAASA,UAAUA,CACxBC,IAA6E,EAC7EC,IAA4C,EAC5CC,IAAwB,EACkC;AAC1D,EAAA,MAAMC,UAA6D,GACjE,OAAOH,IAAI,KAAK,QAAQ,GAAG;AAAEI,IAAAA,IAAI,EAAEJ,IAAI;AAAEK,IAAAA,EAAE,EAAEJ;AAAe,GAAC,GAAGD,IAAI;AACtE,EAAA,MAAMM,OAA0B,GAAG,CAAC,OAAON,IAAI,KAAK,QAAQ,GAAGE,IAAI,GAAID,IAA0B,KAAK,EAAE;AACxG,EAAA,MAAMM,YAAY,GAAGC,mBAAmB,CAACF,OAAO,CAAC;AACjD,EAAA,MAAMG,UAAgC,GAAG;IACvCN,UAAU;AACVO,IAAAA,EAAE,EAAE,YAAY;IAChBC,YAAY,EAAEC,SAAS,CAACC,QAAQ,CAACV,UAAU,CAACC,IAAI,CAAC;GAClD;AAEDU,EAAAA,qBAAqB,CAACL,UAAU,EAAEH,OAAO,CAAC;AAE1C,EAAA,MAAMS,GAAG,GAAGC,YAAY,CAACP,UAAU,CAAC;AACpC,EAAA,MAAMQ,OAAO,GAAG,IAAIC,OAAO,EAAE;AAC7BD,EAAAA,OAAO,CAACE,MAAM,CAAC,QAAQ,EAAE,gCAAgC,CAAC;EAE1D,OAAO;IACLJ,GAAG,EAAET,OAAO,CA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AAC,GAAA,CAAAC,KAAA,CAAA,GAAA,CAAAC,IAAA,IAAA;AAAA,IAAA,IAAA,CAAAA,IAAA,EAAA;MAAA,MAAAC,IAAAA,KAAA,CAAO,CAAsE,oEAAA,CAAA,CAAA;AAAA;GAAEV,EAAAA,UAAU,CAACzB,UAAU,CAAC,CAAA,GAAA,EAAA;AAErG,EAAA,MAAMM,UAAkC,GAAG;AACzCN,IAAAA,UAAU,EAAEA,UAAU;AACtBO,IAAAA,EAAE,EAAE,cAAc;IAClBC,YAAY,EAAEC,SAAS,CAACC,QAAQ,CAACV,UAAU,CAACC,IAAI,CAAC;GAClD;AAEDU,EAAAA,qBAAqB,CAACL,UAAU,EAAEH,OAAO,CAAC;AAE1C,EAAA,MAAMS,GAAG,GAAGC,YAAY,CAACP,UAAU,CAAC;AACpC,EAAA,MAAMQ,OAAO,GAAG,IAAIC,OAAO,EAAE;AAC7BD,EAAAA,OAAO,CAACE,MAAM,CAAC,QAAQ,EAAE,gCAAgC,CAAC;EAE1D,OAAO;IACLJ,GAAG;AACHS,IAAAA,MAAM,EAAElB,OAAO,CAACoC,KAAK,GAAG,OAAO,GAAG,KAAK;IACvCzB,OAAO;AACPP,IAAAA,EAAE,EAAE,cAAc;AAClB6B,IAAAA,IAAI,EAAE;AACJT,MAAAA,MAAM,EAAE3B;KACT;IACDsB,OAAO,EAAE,CAACtB,UAAU;GACrB;AACH;;;;"}
|
package/dist/string.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { g as camelize, h as capitalize, d as clear, e as clearRules, f as dasherize, i as irregular, l as loadIrregular, c as loadUncountable, b as plural, p as pluralize, r as resetToDefaults, k as setMaxLRUCacheSize, a as singular, s as singularize, u as uncountable, j as underscore } from "./inflect-C1laviCe.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="1200pt" height="1200pt" version="1.1" viewBox="0 0 1200 1200" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="#0969da" d="m1096.3 402.82c-53.148-53.008-117.12-79.516-191.93-79.516-67.488 0-126.55 21.938-177.16 65.805-50.617 43.871-80.988 98.285-91.113 163.25l53.57 4.2188c14.625 0.28125 25.449 6.75 32.48 19.406h18.984c11.809 0 17.715 5.7617 17.715 17.293s-5.9062 17.293-17.715 17.293h-17.297c-6.75 14.344-18.137 21.797-34.168 22.359l-53.57 4.6406c10.125 64.68 40.496 118.95 91.113 162.82 50.617 43.871 109.68 65.805 177.16 65.805 74.805 0 138.78-26.574 191.93-79.723 53.152-53.148 79.727-116.98 79.727-191.51 0-75.086-26.574-139.13-79.727-192.14zm-79.422 185.27c0 2.9531 2.3906 5.3477 5.3438 5.3477 2.9531 0 5.3477-2.3945 5.3477-5.3477 0-2.9492-2.3945-5.3438-5.3477-5.3438-2.9531 0-5.3438 2.3945-5.3438 5.3438zm-104.54-111.07c0 2.9531 2.3945 5.3477 5.3438 5.3477 2.9531 0 5.3477-2.3945 5.3477-5.3477s-2.3945-5.3438-5.3477-5.3438c-2.9492 0-5.3438 2.3906-5.3438 5.3438zm-12.473 0c0 2.9531 2.3906 5.3477 5.3438 5.3477s5.3477-2.3945 5.3477-5.3477-2.3945-5.3438-5.3477-5.3438-5.3438 2.3906-5.3438 5.3438zm117.01 123.55c0 2.9492 2.3906 5.3438 5.3438 5.3438 2.9531 0 5.3477-2.3945 5.3477-5.3438 0-2.9531-2.3945-5.3477-5.3477-5.3477-2.9531 0-5.3438 2.3945-5.3438 5.3477zm-104.54 111.66c0 2.9531 2.3945 5.3477 5.3438 5.3477 2.9531 0 5.3477-2.3945 5.3477-5.3477s-2.3945-5.3438-5.3477-5.3438c-2.9492 0-5.3438 2.3906-5.3438 5.3438zm-12.473 0c0 2.9531 2.3906 5.3477 5.3438 5.3477s5.3477-2.3945 5.3477-5.3477-2.3945-5.3438-5.3477-5.3438-5.3438 2.3906-5.3438 5.3438zm-848-318.48c14.062-2.5312 30.934-4.5 50.621-5.9062l-46.402-0.84375zm499.86 169.15c-8.7188-2.25-18.141-8.7188-28.266-19.402l-101.23-103.35h-111.36l173.79 126.12v4.2188c21.652 6.1836 44.008 3.6562 67.07-7.5938zm47.664-148.48c-0.84375 3.3711-2.8125 6.6055-5.9062 9.6992h-5.0625l-6.3242-5.0625h-79.305v-4.6367zm-5.9062-16.031c3.0938 3.0938 5.0625 6.4688 5.9062 10.125h-96.598v-4.6406h79.305l6.3242-5.4844zm-541.62 397.78 4.2188 6.7461 46.402-0.84375c-22.5-2.2461-39.371-4.2148-50.621-5.9023zm499.86-169.15c-23.062-11.531-45.418-14.062-67.07-7.5938v4.2188l-173.79 126.12h111.36l101.23-103.77c10.406-10.684 19.828-17.012 28.266-18.98zm47.664 148.48h-96.598v-4.6406h79.305l6.3242-5.4805h5.0625c3.0938 3.6523 5.0625 7.0273 5.9062 10.121zm-5.9062 15.609h-5.0625l-6.3242-5.0625h-79.305v-4.6406h96.598c-0.84375 3.0938-2.8125 6.3281-5.9062 9.7031zm-102.5 9.6992c3.6562 1.4062 7.4531 2.1094 11.391 2.1094h64.961c24.746 0 37.121-8.4336 37.121-25.309 0-8.4375-4.6406-14.691-13.922-18.77-9.2773-4.0781-17.012-6.1172-23.199-6.1172h-64.961c-4.7812 0-8.5781 0.5625-11.391 1.6875h-333.66c-5.0625 0-28.543 1.6172-70.445 4.8516-41.902 3.2344-62.852 7.3828-62.852 12.441v11.812c0 4.5 20.949 8.5078 62.852 12.023 41.902 3.5156 65.383 5.2695 70.445 5.2695zm125.28-207.54h-42.602c-3.375 1.125-3.375 2.25 0 3.375h42.602zm-43.445 8.4375h-5.4844v-13.5h5.4844c17.152-6.1875 33.605-9.9844 49.352-11.391l4.6406-25.309 4.6406 0.42188c0.5625-4.2188 1.6875-10.262 3.375-18.137-28.684-0.5625-64.398 1.6875-107.14 6.75 3.6562 4.2148 7.4531 7.8711 11.391 10.965 4.7812 3.375 9.4219 5.625 13.918 6.75l12.656 2.9531-11.812 5.9062c-13.496 6.75-30.23 10.121-50.195 10.121-5.0625 0-8.5781-0.14062-10.547-0.42188-4.2188-0.5625-7.5898-1.1211-10.121-1.6836l-3.375-1.2656v-5.4844l-24.043-17.297c-41.34 5.625-69.32 8.5781-83.945 8.8594-31.496 0.28125-47.242 11.953-47.242 35.012 0 22.215 15.746 33.887 47.242 35.012 18.844 0.28125 46.824 3.2344 83.945 8.8594l24.043-17.297v-5.4844l3.375-1.2656c2.5312-0.84375 5.9023-1.4062 10.121-1.6875 1.9688-0.28125 5.4844-0.42187 10.547-0.42187 19.965 0 36.699 3.375 50.195 10.125l11.812 5.4844-12.656 3.375c-4.4961 0.84375-9.1367 3.0938-13.918 6.75-3.6562 2.2461-7.4531 5.7617-11.391 10.543 40.777 5.0625 76.492 7.4531 107.14 7.1719-1.6875-7.3125-2.8125-13.359-3.375-18.137h-4.6406l-4.6406-24.891c-17.434-2.25-33.887-6.043-49.352-11.387zm48.508-20.25c-12.652 1.6875-23.762 3.9375-33.324 6.75h29.105l3.7969-4.2188zm-4.2188 20.25h-29.105c9.5625 2.5312 20.672 4.7812 33.324 6.7461l-0.42188-2.5273zm136.67-8.4375c0-8.4375-4.2188-12.656-12.652-12.656h-21.516c-6.4688-12.652-16.59-18.98-30.371-18.98l-58.211-5.0625-5.9062 29.527-4.2188 5.0625v7.5938l4.2188 5.0625 5.9062 29.105 58.211-5.0625c15.469 0 26.012-7.3125 31.637-21.934h20.25c8.4336 0 12.652-4.2188 12.652-12.656zm-46.82 1.6875c0-11.531-5.9062-17.297-17.719-17.297-11.527 0-17.293 5.7656-17.293 17.297 0 11.812 5.7656 17.715 17.293 17.715 11.812 0 17.719-5.9023 17.719-17.715zm4.6406 0c0 14.902-7.4531 22.355-22.359 22.355-14.902 0-22.355-7.4531-22.355-22.355 0-14.906 7.4531-22.355 22.355-22.355 14.906 0 22.359 7.4492 22.359 22.355zm-13.922 0c0-5.625-2.8125-8.4375-8.4375-8.4375-5.3438 0-8.0156 2.8125-8.0156 8.4375s2.6719 8.4375 8.0156 8.4375c5.625 0 8.4375-2.8125 8.4375-8.4375zm4.6406 0c0 8.7188-4.3594 13.078-13.078 13.078-8.4375 0-12.652-4.3594-12.652-13.078s4.2148-13.078 12.652-13.078c8.7188 0 13.078 4.3594 13.078 13.078zm-43.871-2.1094v4.2188h-35.012v-4.2188zm258.58 2.1094c-0.5625-8.4375-4.7812-12.656-12.656-12.656-8.4336 0-12.652 4.2188-12.652 12.656s4.2188 12.656 12.652 12.656c8.4375 0 12.656-4.2188 12.656-12.656zm4.6406 0c0 11.531-5.7656 17.293-17.297 17.293-11.527 0-17.293-5.7617-17.293-17.293s5.7656-17.297 17.293-17.297c11.531 0 17.297 5.7656 17.297 17.297zm32.48 0c0-13.781-4.9219-25.59-14.766-35.434-9.5586-9.5625-21.23-14.344-35.012-14.344-15.184 0-31.777 5.7656-49.773 17.297-18.559 11.531-27.84 22.355-27.84 32.48 0 9.8438 9.2812 20.668 27.84 32.48 17.996 11.531 34.59 17.293 49.773 17.293 13.781 0 25.453-4.918 35.012-14.762 9.8438-9.5625 14.766-21.234 14.766-35.012zm5.0625 0c0 14.902-5.3438 27.699-16.031 38.387-10.684 10.684-23.621 16.027-38.809 16.027-15.746 0-33.18-6.0469-52.305-18.137-20.246-12.656-30.371-24.746-30.371-36.277s10.125-23.762 30.371-36.699c19.125-12.094 36.559-18.137 52.305-18.137 14.625 0 27.562 5.3398 38.809 16.027 10.688 10.969 16.031 23.902 16.031 38.809zm-54.418-29.105c-3.9336 0-10.262 1.6875-18.98 5.0625-7.875 3.9375-11.812 6.4648-11.812 7.5898v32.48c0 3.0938 3.9375 5.625 11.812 7.5938 7.875 3.375 14.203 5.0625 18.98 5.0625 19.406 0 29.391-9.2812 29.953-27.84 0-19.688-9.9844-29.668-29.953-29.949zm34.59 29.105v0.84375c0 21.371-11.527 32.34-34.59 32.902-4.4961 0-11.527-1.8281-21.09-5.4844-7.0312-3.9375-10.969-6.3281-11.809-7.1719-1.6875-1.4062-2.5312-3.0938-2.5312-5.0625v-32.48c0-1.4062 0.70312-2.9492 2.1094-4.6367 3.0898-2.8125 7.168-5.2031 12.23-7.1719 9-3.6562 16.031-5.4844 21.09-5.4844 22.5 0.28125 34.027 11.531 34.59 33.746zm-448.4-206.27h-333.66c-5.0625 0-28.543 1.6875-70.445 5.0625-41.902 3.375-62.852 7.5938-62.852 12.656v11.387c0 4.7812 20.949 8.8594 62.852 12.234 41.902 3.375 65.383 5.0625 70.445 5.0625h333.66c3.6562 1.4062 7.4531 2.1094 11.391 2.1094h64.961c5.3438 0 12.867-2.25 22.566-6.75 9.7031-4.5 14.555-10.547 14.555-18.137 0.28125-16.875-12.094-25.312-37.121-25.312h-64.961c-4.7812 0-8.5781 0.5625-11.391 1.6875z" fill-rule="evenodd"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="1200pt" height="1200pt" version="1.1" viewBox="0 0 1200 1200" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="#FFC474" d="m1096.3 402.82c-53.148-53.008-117.12-79.516-191.93-79.516-67.488 0-126.55 21.938-177.16 65.805-50.617 43.871-80.988 98.285-91.113 163.25l53.57 4.2188c14.625 0.28125 25.449 6.75 32.48 19.406h18.984c11.809 0 17.715 5.7617 17.715 17.293s-5.9062 17.293-17.715 17.293h-17.297c-6.75 14.344-18.137 21.797-34.168 22.359l-53.57 4.6406c10.125 64.68 40.496 118.95 91.113 162.82 50.617 43.871 109.68 65.805 177.16 65.805 74.805 0 138.78-26.574 191.93-79.723 53.152-53.148 79.727-116.98 79.727-191.51 0-75.086-26.574-139.13-79.727-192.14zm-79.422 185.27c0 2.9531 2.3906 5.3477 5.3438 5.3477 2.9531 0 5.3477-2.3945 5.3477-5.3477 0-2.9492-2.3945-5.3438-5.3477-5.3438-2.9531 0-5.3438 2.3945-5.3438 5.3438zm-104.54-111.07c0 2.9531 2.3945 5.3477 5.3438 5.3477 2.9531 0 5.3477-2.3945 5.3477-5.3477s-2.3945-5.3438-5.3477-5.3438c-2.9492 0-5.3438 2.3906-5.3438 5.3438zm-12.473 0c0 2.9531 2.3906 5.3477 5.3438 5.3477s5.3477-2.3945 5.3477-5.3477-2.3945-5.3438-5.3477-5.3438-5.3438 2.3906-5.3438 5.3438zm117.01 123.55c0 2.9492 2.3906 5.3438 5.3438 5.3438 2.9531 0 5.3477-2.3945 5.3477-5.3438 0-2.9531-2.3945-5.3477-5.3477-5.3477-2.9531 0-5.3438 2.3945-5.3438 5.3477zm-104.54 111.66c0 2.9531 2.3945 5.3477 5.3438 5.3477 2.9531 0 5.3477-2.3945 5.3477-5.3477s-2.3945-5.3438-5.3477-5.3438c-2.9492 0-5.3438 2.3906-5.3438 5.3438zm-12.473 0c0 2.9531 2.3906 5.3477 5.3438 5.3477s5.3477-2.3945 5.3477-5.3477-2.3945-5.3438-5.3477-5.3438-5.3438 2.3906-5.3438 5.3438zm-848-318.48c14.062-2.5312 30.934-4.5 50.621-5.9062l-46.402-0.84375zm499.86 169.15c-8.7188-2.25-18.141-8.7188-28.266-19.402l-101.23-103.35h-111.36l173.79 126.12v4.2188c21.652 6.1836 44.008 3.6562 67.07-7.5938zm47.664-148.48c-0.84375 3.3711-2.8125 6.6055-5.9062 9.6992h-5.0625l-6.3242-5.0625h-79.305v-4.6367zm-5.9062-16.031c3.0938 3.0938 5.0625 6.4688 5.9062 10.125h-96.598v-4.6406h79.305l6.3242-5.4844zm-541.62 397.78 4.2188 6.7461 46.402-0.84375c-22.5-2.2461-39.371-4.2148-50.621-5.9023zm499.86-169.15c-23.062-11.531-45.418-14.062-67.07-7.5938v4.2188l-173.79 126.12h111.36l101.23-103.77c10.406-10.684 19.828-17.012 28.266-18.98zm47.664 148.48h-96.598v-4.6406h79.305l6.3242-5.4805h5.0625c3.0938 3.6523 5.0625 7.0273 5.9062 10.121zm-5.9062 15.609h-5.0625l-6.3242-5.0625h-79.305v-4.6406h96.598c-0.84375 3.0938-2.8125 6.3281-5.9062 9.7031zm-102.5 9.6992c3.6562 1.4062 7.4531 2.1094 11.391 2.1094h64.961c24.746 0 37.121-8.4336 37.121-25.309 0-8.4375-4.6406-14.691-13.922-18.77-9.2773-4.0781-17.012-6.1172-23.199-6.1172h-64.961c-4.7812 0-8.5781 0.5625-11.391 1.6875h-333.66c-5.0625 0-28.543 1.6172-70.445 4.8516-41.902 3.2344-62.852 7.3828-62.852 12.441v11.812c0 4.5 20.949 8.5078 62.852 12.023 41.902 3.5156 65.383 5.2695 70.445 5.2695zm125.28-207.54h-42.602c-3.375 1.125-3.375 2.25 0 3.375h42.602zm-43.445 8.4375h-5.4844v-13.5h5.4844c17.152-6.1875 33.605-9.9844 49.352-11.391l4.6406-25.309 4.6406 0.42188c0.5625-4.2188 1.6875-10.262 3.375-18.137-28.684-0.5625-64.398 1.6875-107.14 6.75 3.6562 4.2148 7.4531 7.8711 11.391 10.965 4.7812 3.375 9.4219 5.625 13.918 6.75l12.656 2.9531-11.812 5.9062c-13.496 6.75-30.23 10.121-50.195 10.121-5.0625 0-8.5781-0.14062-10.547-0.42188-4.2188-0.5625-7.5898-1.1211-10.121-1.6836l-3.375-1.2656v-5.4844l-24.043-17.297c-41.34 5.625-69.32 8.5781-83.945 8.8594-31.496 0.28125-47.242 11.953-47.242 35.012 0 22.215 15.746 33.887 47.242 35.012 18.844 0.28125 46.824 3.2344 83.945 8.8594l24.043-17.297v-5.4844l3.375-1.2656c2.5312-0.84375 5.9023-1.4062 10.121-1.6875 1.9688-0.28125 5.4844-0.42187 10.547-0.42187 19.965 0 36.699 3.375 50.195 10.125l11.812 5.4844-12.656 3.375c-4.4961 0.84375-9.1367 3.0938-13.918 6.75-3.6562 2.2461-7.4531 5.7617-11.391 10.543 40.777 5.0625 76.492 7.4531 107.14 7.1719-1.6875-7.3125-2.8125-13.359-3.375-18.137h-4.6406l-4.6406-24.891c-17.434-2.25-33.887-6.043-49.352-11.387zm48.508-20.25c-12.652 1.6875-23.762 3.9375-33.324 6.75h29.105l3.7969-4.2188zm-4.2188 20.25h-29.105c9.5625 2.5312 20.672 4.7812 33.324 6.7461l-0.42188-2.5273zm136.67-8.4375c0-8.4375-4.2188-12.656-12.652-12.656h-21.516c-6.4688-12.652-16.59-18.98-30.371-18.98l-58.211-5.0625-5.9062 29.527-4.2188 5.0625v7.5938l4.2188 5.0625 5.9062 29.105 58.211-5.0625c15.469 0 26.012-7.3125 31.637-21.934h20.25c8.4336 0 12.652-4.2188 12.652-12.656zm-46.82 1.6875c0-11.531-5.9062-17.297-17.719-17.297-11.527 0-17.293 5.7656-17.293 17.297 0 11.812 5.7656 17.715 17.293 17.715 11.812 0 17.719-5.9023 17.719-17.715zm4.6406 0c0 14.902-7.4531 22.355-22.359 22.355-14.902 0-22.355-7.4531-22.355-22.355 0-14.906 7.4531-22.355 22.355-22.355 14.906 0 22.359 7.4492 22.359 22.355zm-13.922 0c0-5.625-2.8125-8.4375-8.4375-8.4375-5.3438 0-8.0156 2.8125-8.0156 8.4375s2.6719 8.4375 8.0156 8.4375c5.625 0 8.4375-2.8125 8.4375-8.4375zm4.6406 0c0 8.7188-4.3594 13.078-13.078 13.078-8.4375 0-12.652-4.3594-12.652-13.078s4.2148-13.078 12.652-13.078c8.7188 0 13.078 4.3594 13.078 13.078zm-43.871-2.1094v4.2188h-35.012v-4.2188zm258.58 2.1094c-0.5625-8.4375-4.7812-12.656-12.656-12.656-8.4336 0-12.652 4.2188-12.652 12.656s4.2188 12.656 12.652 12.656c8.4375 0 12.656-4.2188 12.656-12.656zm4.6406 0c0 11.531-5.7656 17.293-17.297 17.293-11.527 0-17.293-5.7617-17.293-17.293s5.7656-17.297 17.293-17.297c11.531 0 17.297 5.7656 17.297 17.297zm32.48 0c0-13.781-4.9219-25.59-14.766-35.434-9.5586-9.5625-21.23-14.344-35.012-14.344-15.184 0-31.777 5.7656-49.773 17.297-18.559 11.531-27.84 22.355-27.84 32.48 0 9.8438 9.2812 20.668 27.84 32.48 17.996 11.531 34.59 17.293 49.773 17.293 13.781 0 25.453-4.918 35.012-14.762 9.8438-9.5625 14.766-21.234 14.766-35.012zm5.0625 0c0 14.902-5.3438 27.699-16.031 38.387-10.684 10.684-23.621 16.027-38.809 16.027-15.746 0-33.18-6.0469-52.305-18.137-20.246-12.656-30.371-24.746-30.371-36.277s10.125-23.762 30.371-36.699c19.125-12.094 36.559-18.137 52.305-18.137 14.625 0 27.562 5.3398 38.809 16.027 10.688 10.969 16.031 23.902 16.031 38.809zm-54.418-29.105c-3.9336 0-10.262 1.6875-18.98 5.0625-7.875 3.9375-11.812 6.4648-11.812 7.5898v32.48c0 3.0938 3.9375 5.625 11.812 7.5938 7.875 3.375 14.203 5.0625 18.98 5.0625 19.406 0 29.391-9.2812 29.953-27.84 0-19.688-9.9844-29.668-29.953-29.949zm34.59 29.105v0.84375c0 21.371-11.527 32.34-34.59 32.902-4.4961 0-11.527-1.8281-21.09-5.4844-7.0312-3.9375-10.969-6.3281-11.809-7.1719-1.6875-1.4062-2.5312-3.0938-2.5312-5.0625v-32.48c0-1.4062 0.70312-2.9492 2.1094-4.6367 3.0898-2.8125 7.168-5.2031 12.23-7.1719 9-3.6562 16.031-5.4844 21.09-5.4844 22.5 0.28125 34.027 11.531 34.59 33.746zm-448.4-206.27h-333.66c-5.0625 0-28.543 1.6875-70.445 5.0625-41.902 3.375-62.852 7.5938-62.852 12.656v11.387c0 4.7812 20.949 8.8594 62.852 12.234 41.902 3.375 65.383 5.0625 70.445 5.0625h333.66c3.6562 1.4062 7.4531 2.1094 11.391 2.1094h64.961c5.3438 0 12.867-2.25 22.566-6.75 9.7031-4.5 14.555-10.547 14.555-18.137 0.28125-16.875-12.094-25.312-37.121-25.312h-64.961c-4.7812 0-8.5781 0.5625-11.391 1.6875z" fill-rule="evenodd"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="M91.36 33.566q-6.645-6.623-15.997-6.625-8.439 0-14.761 5.485-6.329 5.484-7.594 13.605l4.465.352Q59.3 46.418 60.18 48h1.582q1.476 0 1.476 1.441 0 1.44-1.476 1.438H60.32q-.843 1.793-2.847 1.863l-4.465.387q1.266 8.085 7.594 13.57t14.761 5.485q9.352 0 15.996-6.645 6.645-6.646 6.645-15.957 0-9.389-6.645-16.012Zm-6.622 15.442a.445.445 0 1 0 .89 0 .445.445 0 0 0-.89 0m-8.71-9.258c0 .246.199.45.445.45a.45.45 0 0 0 .445-.45.445.445 0 1 0-.89 0m-1.04 0c0 .246.2.45.446.45a.45.45 0 0 0 .445-.45.445.445 0 1 0-.89 0m9.75 10.297a.445.445 0 1 0 .89 0 .445.445 0 0 0-.89 0m-8.71 9.305a.445.445 0 1 0 .89 0 .445.445 0 0 0-.89 0m-1.04 0a.445.445 0 1 0 .89 0 .445.445 0 0 0-.89 0M4.32 32.812q1.757-.315 4.22-.492l-3.868-.07ZM45.977 46.91q-1.09-.28-2.356-1.617l-8.437-8.613h-9.278l14.48 10.508v.351q2.708.774 5.59-.633Zm3.972-12.375q-.105.421-.492.809h-.422l-.527-.422h-6.61v-.387Zm-.492-1.336q.387.388.492.844H41.9v-.387h6.609l.527-.457ZM4.32 66.348l.352.562 3.867-.07q-2.812-.282-4.219-.492M45.977 52.25q-2.883-1.44-5.59-.633v.352L25.907 62.48h9.277l8.437-8.648q1.3-1.335 2.356-1.582m3.972 12.375H41.9v-.387h6.609l.527-.457h.422q.387.457.492.844m-.492 1.3h-.422l-.527-.421h-6.61v-.387h8.051q-.105.387-.492.809m-8.543.81q.457.175.95.175h5.413q3.094 0 3.094-2.11 0-1.052-1.16-1.562t-1.934-.511h-5.414q-.598 0-.949.14H13.11q-.633.001-5.87.406-5.24.404-5.239 1.036v.984q0 .561 5.238 1 5.239.44 5.871.441Zm10.441-17.297h-3.55q-.423.14 0 .28h3.55Zm-3.62.703h-.458v-1.125h.457q2.145-.773 4.114-.95l.386-2.109.387.035c.047-.351.14-.851.281-1.508q-3.585-.07-8.93.563.458.523.95.91.597.422 1.16.563l1.055.246-.985.492q-1.688.843-4.183.844-.633 0-.88-.036a10 10 0 0 1-.843-.14l-.281-.106v-.457l-2.004-1.441q-5.162.704-6.992.738-3.938.035-3.938 2.918 0 2.777 3.938 2.918 2.356.036 6.992.738l2.004-1.441v-.457l.281-.106q.316-.105.844-.14.246-.035.879-.035 2.496 0 4.183.843l.985.457-1.055.282q-.563.106-1.16.562-.457.281-.95.88 5.1.631 8.93.597-.21-.915-.28-1.512h-.388l-.386-2.074a20.7 20.7 0 0 1-4.114-.95m4.042-1.688q-1.581.21-2.777.563h2.426l.316-.352Zm-.351 1.688H49q1.196.316 2.777.562l-.035-.21Zm11.386-.703q0-1.055-1.05-1.055h-1.793q-.81-1.582-2.532-1.582l-4.851-.422-.492 2.46-.352.423v.633l.352.421.492 2.426 4.852-.422q1.933 0 2.636-1.828h1.688q1.05 0 1.05-1.054m-3.898.14q0-1.44-1.477-1.441-1.44 0-1.44 1.441 0 1.476 1.44 1.477 1.477 0 1.477-1.477m.387 0q0 1.863-1.864 1.863-1.863 0-1.863-1.863t1.864-1.863 1.863 1.863m-1.16 0q0-.703-.703-.703-.668 0-.668.703t.667.703q.704 0 .704-.703m.386 0q0 1.09-1.09 1.09-1.054 0-1.054-1.09t1.054-1.09q1.09 0 1.09 1.09m-3.656-.176v.352h-2.918v-.352Zm21.547.176q-.07-1.055-1.055-1.055-1.054 0-1.054 1.055t1.054 1.055 1.055-1.055m.387 0q0 1.442-1.442 1.442-1.44 0-1.441-1.442 0-1.44 1.441-1.441 1.442 0 1.442 1.441m2.707 0q0-1.723-1.23-2.953-1.196-1.195-2.919-1.195-1.898 0-4.148 1.441-2.32 1.441-2.32 2.707 0 1.23 2.32 2.707 2.25 1.442 4.148 1.442 1.723 0 2.918-1.23 1.23-1.196 1.23-2.919m.422 0q0 1.863-1.336 3.2-1.337 1.335-3.235 1.335-1.968 0-4.36-1.511-2.53-1.583-2.53-3.024 0-1.44 2.53-3.058c1.595-1.008 3.048-1.508 4.36-1.508 1.219 0 2.297.441 3.235 1.332q1.335 1.371 1.336 3.234m-4.536-2.426q-.492 0-1.582.422-.984.493-.984.633v2.707q0 .387.984.633.985.422 1.582.422 2.427 0 2.497-2.32 0-2.461-2.497-2.497m2.883 2.426v.07q0 2.673-2.883 2.743-.562 0-1.757-.457-.879-.493-.985-.598a.53.53 0 0 1-.21-.422v-2.707q0-.175.175-.387.387-.351 1.02-.597 1.125-.457 1.757-.457 2.813.034 2.883 2.812M40.914 32.391H13.11q-.633 0-5.87.422-5.24.42-5.239 1.054v.95q0 .597 5.238 1.019t5.871.422h27.805q.457.176.95.176h5.413q.667 0 1.88-.563t1.214-1.512q.035-2.109-3.094-2.109h-5.414q-.598 0-.949.14m0 0" style="stroke:none;fill-rule:evenodd;fill:#ffc474;fill-opacity:1"/></svg>
|