@warp-drive/utilities 5.9.0-alpha.9 → 5.9.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/cjs-dist/string.cjs +349 -331
  2. package/cjs-dist/string.cjs.map +1 -0
  3. package/declarations/-private.d.ts +12 -1
  4. package/declarations/-private.d.ts.map +1 -0
  5. package/declarations/active-record.d.ts +260 -3
  6. package/declarations/active-record.d.ts.map +1 -0
  7. package/declarations/derivations.d.ts +26 -23
  8. package/declarations/derivations.d.ts.map +1 -0
  9. package/declarations/handlers.d.ts +282 -9
  10. package/declarations/handlers.d.ts.map +1 -0
  11. package/declarations/index-BeMAuqgZ.d.ts +462 -0
  12. package/declarations/index-BeMAuqgZ.d.ts.map +1 -0
  13. package/declarations/index.d.ts +2 -208
  14. package/declarations/json-api.d.ts +496 -5
  15. package/declarations/json-api.d.ts.map +1 -0
  16. package/declarations/rest.d.ts +258 -3
  17. package/declarations/rest.d.ts.map +1 -0
  18. package/declarations/string.d.ts +164 -13
  19. package/declarations/string.d.ts.map +1 -0
  20. package/dist/-private.js +2 -6
  21. package/dist/active-record.js +254 -379
  22. package/dist/active-record.js.map +1 -0
  23. package/dist/builder-utils-BkXwUT0x.js +16 -0
  24. package/dist/builder-utils-BkXwUT0x.js.map +1 -0
  25. package/dist/derivations.js +26 -26
  26. package/dist/derivations.js.map +1 -0
  27. package/dist/handlers.js +240 -283
  28. package/dist/handlers.js.map +1 -0
  29. package/dist/index.js +357 -335
  30. package/dist/index.js.map +1 -0
  31. package/dist/inflections-DzBsjJqj.js +80 -0
  32. package/dist/inflections-DzBsjJqj.js.map +1 -0
  33. package/dist/json-api.js +470 -706
  34. package/dist/json-api.js.map +1 -0
  35. package/dist/rest.js +254 -377
  36. package/dist/rest.js.map +1 -0
  37. package/dist/string-CWmAluxh.js +290 -0
  38. package/dist/string-CWmAluxh.js.map +1 -0
  39. package/dist/string.js +3 -1
  40. package/dist/unpkg/dev/-private.js +2 -6
  41. package/dist/unpkg/dev/active-record.js +253 -378
  42. package/dist/unpkg/dev/active-record.js.map +1 -0
  43. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js +16 -0
  44. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js.map +1 -0
  45. package/dist/unpkg/dev/derivations.js +26 -26
  46. package/dist/unpkg/dev/derivations.js.map +1 -0
  47. package/dist/unpkg/dev/handlers.js +238 -282
  48. package/dist/unpkg/dev/handlers.js.map +1 -0
  49. package/dist/unpkg/dev/index.js +356 -336
  50. package/dist/unpkg/dev/index.js.map +1 -0
  51. package/dist/unpkg/dev/inflections-DzBsjJqj.js +80 -0
  52. package/dist/unpkg/dev/inflections-DzBsjJqj.js.map +1 -0
  53. package/dist/unpkg/dev/json-api.js +469 -706
  54. package/dist/unpkg/dev/json-api.js.map +1 -0
  55. package/dist/unpkg/dev/rest.js +253 -376
  56. package/dist/unpkg/dev/rest.js.map +1 -0
  57. package/dist/unpkg/dev/string-j4ur-TDs.js +289 -0
  58. package/dist/unpkg/dev/string-j4ur-TDs.js.map +1 -0
  59. package/dist/unpkg/dev/string.js +3 -1
  60. package/dist/unpkg/dev-deprecated/-private.js +2 -6
  61. package/dist/unpkg/dev-deprecated/active-record.js +253 -378
  62. package/dist/unpkg/dev-deprecated/active-record.js.map +1 -0
  63. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js +16 -0
  64. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  65. package/dist/unpkg/dev-deprecated/derivations.js +26 -26
  66. package/dist/unpkg/dev-deprecated/derivations.js.map +1 -0
  67. package/dist/unpkg/dev-deprecated/handlers.js +238 -282
  68. package/dist/unpkg/dev-deprecated/handlers.js.map +1 -0
  69. package/dist/unpkg/dev-deprecated/index.js +356 -336
  70. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  71. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js +80 -0
  72. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js.map +1 -0
  73. package/dist/unpkg/dev-deprecated/json-api.js +469 -706
  74. package/dist/unpkg/dev-deprecated/json-api.js.map +1 -0
  75. package/dist/unpkg/dev-deprecated/rest.js +253 -376
  76. package/dist/unpkg/dev-deprecated/rest.js.map +1 -0
  77. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js +289 -0
  78. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +1 -0
  79. package/dist/unpkg/dev-deprecated/string.js +3 -1
  80. package/dist/unpkg/prod/-private.js +2 -6
  81. package/dist/unpkg/prod/active-record.js +236 -351
  82. package/dist/unpkg/prod/active-record.js.map +1 -0
  83. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js +16 -0
  84. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js.map +1 -0
  85. package/dist/unpkg/prod/derivations.js +26 -26
  86. package/dist/unpkg/prod/derivations.js.map +1 -0
  87. package/dist/unpkg/prod/handlers.js +231 -272
  88. package/dist/unpkg/prod/handlers.js.map +1 -0
  89. package/dist/unpkg/prod/index.js +265 -215
  90. package/dist/unpkg/prod/index.js.map +1 -0
  91. package/dist/unpkg/prod/inflections-DzBsjJqj.js +80 -0
  92. package/dist/unpkg/prod/inflections-DzBsjJqj.js.map +1 -0
  93. package/dist/unpkg/prod/json-api.js +446 -669
  94. package/dist/unpkg/prod/json-api.js.map +1 -0
  95. package/dist/unpkg/prod/rest.js +236 -349
  96. package/dist/unpkg/prod/rest.js.map +1 -0
  97. package/dist/unpkg/prod/string-T1ahjLdj.js +283 -0
  98. package/dist/unpkg/prod/string-T1ahjLdj.js.map +1 -0
  99. package/dist/unpkg/prod/string.js +3 -1
  100. package/dist/unpkg/prod-deprecated/-private.js +2 -6
  101. package/dist/unpkg/prod-deprecated/active-record.js +236 -351
  102. package/dist/unpkg/prod-deprecated/active-record.js.map +1 -0
  103. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js +16 -0
  104. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  105. package/dist/unpkg/prod-deprecated/derivations.js +26 -26
  106. package/dist/unpkg/prod-deprecated/derivations.js.map +1 -0
  107. package/dist/unpkg/prod-deprecated/handlers.js +231 -272
  108. package/dist/unpkg/prod-deprecated/handlers.js.map +1 -0
  109. package/dist/unpkg/prod-deprecated/index.js +265 -215
  110. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  111. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js +80 -0
  112. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js.map +1 -0
  113. package/dist/unpkg/prod-deprecated/json-api.js +446 -669
  114. package/dist/unpkg/prod-deprecated/json-api.js.map +1 -0
  115. package/dist/unpkg/prod-deprecated/rest.js +236 -349
  116. package/dist/unpkg/prod-deprecated/rest.js.map +1 -0
  117. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js +283 -0
  118. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +1 -0
  119. package/dist/unpkg/prod-deprecated/string.js +3 -1
  120. package/package.json +9 -9
  121. package/declarations/-private/active-record/find-record.d.ts +0 -64
  122. package/declarations/-private/active-record/query.d.ts +0 -53
  123. package/declarations/-private/active-record/save-record.d.ts +0 -146
  124. package/declarations/-private/builder-utils.d.ts +0 -4
  125. package/declarations/-private/handlers/auto-compress.d.ts +0 -158
  126. package/declarations/-private/handlers/gated.d.ts +0 -19
  127. package/declarations/-private/handlers/meta-doc.d.ts +0 -47
  128. package/declarations/-private/handlers/utils.d.ts +0 -41
  129. package/declarations/-private/json-api/-utils.d.ts +0 -109
  130. package/declarations/-private/json-api/find-record.d.ts +0 -84
  131. package/declarations/-private/json-api/query.d.ts +0 -100
  132. package/declarations/-private/json-api/save-record.d.ts +0 -228
  133. package/declarations/-private/json-api/serialize.d.ts +0 -70
  134. package/declarations/-private/rest/find-record.d.ts +0 -62
  135. package/declarations/-private/rest/query.d.ts +0 -53
  136. package/declarations/-private/rest/save-record.d.ts +0 -146
  137. package/declarations/-private/string/inflect.d.ts +0 -82
  138. package/declarations/-private/string/inflections.d.ts +0 -9
  139. package/declarations/-private/string/transform.d.ts +0 -77
  140. package/dist/builder-utils-Donkk-BZ.js +0 -22
  141. package/dist/inflect-BSG696t-.js +0 -344
  142. package/dist/unpkg/dev/builder-utils-Donkk-BZ.js +0 -22
  143. package/dist/unpkg/dev/inflect-BEv8WqY1.js +0 -343
  144. package/dist/unpkg/dev-deprecated/builder-utils-Donkk-BZ.js +0 -22
  145. package/dist/unpkg/dev-deprecated/inflect-BEv8WqY1.js +0 -343
  146. package/dist/unpkg/prod/builder-utils-Donkk-BZ.js +0 -22
  147. package/dist/unpkg/prod/inflect-Dh9dyEYx.js +0 -333
  148. package/dist/unpkg/prod-deprecated/builder-utils-Donkk-BZ.js +0 -22
  149. package/dist/unpkg/prod-deprecated/inflect-Dh9dyEYx.js +0 -333
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.cjs","names":["DEFAULT_MAX_CACHE_SIZE","LRUCache","constructor","doWork","size","state","Map","get","key","value","delete","set","newValue","k","clear","STRING_DASHERIZE_REGEXP","STRING_DECAMELIZE_REGEXP","STRING_DASHERIZE_CACHE","replace","toLowerCase","dasherize","str","internalDasherize","LRUCache","defaultRules","capitalize","BLANK_REGEX","LAST_WORD_DASHED_REGEX","LAST_WORD_CAMELIZED_REGEX","CAMELIZED_REGEX","SINGULARS","word","_singularize","PLURALS","_pluralize","UNCOUNTABLE","Set","uncountable","IRREGULAR","Map","INVERSE_IRREGULAR","SINGULAR_RULES","singular","reverse","PLURAL_RULES","plurals","add","toLowerCase","loadUncountable","uncountables","forEach","irregular","single","plur","set","loadIrregular","irregularPairs","pair","clear","resetToDefaults","clearRules","v","singularize","get","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","delete","inflect","typeRules","irregulars","isBlank","test","lowercase","wordSplit","exec","lastWord","isCamelized","substitution","match","replace","RegExp"],"sources":["../../../node_modules/.pnpm/@warp-d_f6d5a2b6297864aac1090915a29560e9/node_modules/@warp-drive/core/dist/utils/string.js","../src/-private/string/inflections.ts","../src/-private/string/transform.ts","../src/-private/string/inflect.ts"],"sourcesContent":["import { DEBUG } from '@warp-drive/core/build-config/env';\n\nconst DEFAULT_MAX_CACHE_SIZE = 10_000;\n\n/**\n * An LRUCache implementation with upsert semantics.\n *\n * This implementation is *not* generic, but focuses on\n * performance tuning for the string transformation cases\n * where the key maps to the value very simply.\n *\n * It takes a work function that should generate a new value\n * for a given key when called. It will be called when the key\n * is not found in the cache.\n *\n * It keeps track of the number of hits, misses, and ejections\n * in DEBUG envs, which is useful for tuning the cache size.\n *\n * This is an internal utility class for use by this module\n * and by `@warp-drive/utilities/string`. It is not intended\n * for use outside of these modules at this time.\n *\n * @private\n */\nexport class LRUCache<T, V> {\n declare size: number;\n declare state: Map<T, V>;\n declare doWork: (k: T) => V;\n\n // debug stats\n declare _hits: number;\n declare _misses: number;\n declare _ejected: number;\n\n constructor(doWork: (k: T) => V, size?: number) {\n this.size = size || DEFAULT_MAX_CACHE_SIZE;\n this.state = new Map();\n this.doWork = doWork;\n\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n\n get(key: T): V {\n const value = this.state.get(key);\n if (value) {\n if (DEBUG) {\n this._hits++;\n }\n this.state.delete(key);\n this.state.set(key, value);\n return value;\n }\n if (DEBUG) {\n this._misses++;\n }\n\n const newValue = this.doWork(key);\n this.set(key, newValue);\n return newValue;\n }\n\n set(key: T, value: V): void {\n if (this.state.size === this.size) {\n for (const [k] of this.state) {\n if (DEBUG) {\n this._ejected++;\n }\n this.state.delete(k);\n break;\n }\n }\n this.state.set(key, value);\n }\n\n clear(): void {\n this.state.clear();\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n}\n\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\n/**\n * The {@link LRUCache} backing {@link dasherize}, keyed by the original\n * (un-dasherized) string.\n *\n * @private\n */\nexport const STRING_DASHERIZE_CACHE: LRUCache<string, string> = new LRUCache<string, string>((key: string) =>\n key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-')\n);\n\n/**\n * This is an internal utility function that converts a string\n * to a dasherized format. Library consumers should use the\n * re-exported version from `@warp-drive/utilities/string` instead.\n *\n * This version is only in this location to support a deprecated\n * behavior in the core package and will be removed in a future.\n *\n * @private\n */\nexport function dasherize(str: string): string {\n return STRING_DASHERIZE_CACHE.get(str);\n}\n","export type RulesArray = Array<[RegExp, string]>;\ntype DefaultRulesType = {\n plurals: RulesArray;\n singular: RulesArray;\n irregularPairs: Array<[string, string]>;\n uncountable: string[];\n};\n\nexport const defaultRules: DefaultRulesType = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status|bonus)$/i, '$1es'],\n [/(tu|bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes'],\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(tus|bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status|bonus)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1'],\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies'],\n ],\n\n uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police'],\n};\n","import { dasherize as internalDasherize, LRUCache, STRING_DASHERIZE_CACHE } from '@warp-drive/core/utils/string';\n\n// eslint-disable-next-line no-useless-escape\nconst STRING_CAMELIZE_REGEXP_1 = /(\\-|\\_|\\.|\\s)+(.)?/g;\nconst STRING_CAMELIZE_REGEXP_2 = /(^|\\/)([A-Z])/g;\nconst CAMELIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key\n .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr: string | null) => (chr ? chr.toUpperCase() : ''))\n .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())\n);\n\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\n// eslint-disable-next-line no-useless-escape\nconst STRING_UNDERSCORE_REGEXP_2 = /\\-|\\s+/g;\nconst UNDERSCORE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()\n);\n\nconst STRING_CAPITALIZE_REGEXP = /(^|\\/)([a-z\\u00C0-\\u024F])/g;\nconst CAPITALIZE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())\n);\n\n/**\n * Replaces underscores, spaces, or camelCase with dashes.\n *\n * ```js\n * import { dasherize } from '@warp-drive/utilities/string';\n *\n * dasherize('innerHTML'); // 'inner-html'\n * dasherize('action_name'); // 'action-name'\n * dasherize('css-class-name'); // 'css-class-name'\n * dasherize('my favorite items'); // 'my-favorite-items'\n * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'\n * ```\n *\n * @public\n * @since 4.13.0\n */\nexport const dasherize: (str: string) => string = internalDasherize;\n\n/**\n * Returns the lowerCamelCase form of a string.\n *\n * ```js\n * import { camelize } from '@warp-drive/utilities/string';\n *\n * camelize('innerHTML'); // 'innerHTML'\n * camelize('action_name'); // 'actionName'\n * camelize('css-class-name'); // 'cssClassName'\n * camelize('my favorite items'); // 'myFavoriteItems'\n * camelize('My Favorite Items'); // 'myFavoriteItems'\n * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @since 4.13.0\n */\nexport function camelize(str: string): string {\n return CAMELIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lower\\_case\\_and\\_underscored form of a string.\n *\n * ```js\n * import { underscore } from '@warp-drive/utilities/string';\n *\n * underscore('innerHTML'); // 'inner_html'\n * underscore('action_name'); // 'action_name'\n * underscore('css-class-name'); // 'css_class_name'\n * underscore('my favorite items'); // 'my_favorite_items'\n * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'\n * ```\n *\n * @public\n * @since 4.13.0\n */\nexport function underscore(str: string): string {\n return UNDERSCORE_CACHE.get(str);\n}\n\n/**\n * Returns the Capitalized form of a string\n *\n * ```js\n * import { capitalize } from '@warp-drive/utilities/string';\n *\n * capitalize('innerHTML') // 'InnerHTML'\n * capitalize('action_name') // 'Action_name'\n * capitalize('css-class-name') // 'Css-class-name'\n * capitalize('my favorite items') // 'My favorite items'\n * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'\n * ```\n *\n * @public\n * @since 4.13.0\n */\nexport function capitalize(str: string): string {\n return CAPITALIZE_CACHE.get(str);\n}\n\n/**\n * Sets the maximum size of the LRUCache for all string transformation functions.\n * The default size is 10,000.\n *\n * @public\n * @since 4.13.0\n */\nexport function setMaxLRUCacheSize(size: number): void {\n CAMELIZE_CACHE.size = size;\n UNDERSCORE_CACHE.size = size;\n CAPITALIZE_CACHE.size = size;\n STRING_DASHERIZE_CACHE.size = size;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport { LRUCache } from '@warp-drive/core/utils/string';\n\nimport { defaultRules } from './inflections.ts';\nimport { capitalize } from './transform.ts';\n\nconst BLANK_REGEX = /^\\s*$/;\nconst LAST_WORD_DASHED_REGEX = /([\\w/-]+[_/\\s-])([a-z\\d]+$)/;\nconst LAST_WORD_CAMELIZED_REGEX = /([\\w/\\s-]+)([A-Z][a-z\\d]*$)/;\nconst CAMELIZED_REGEX = /[A-Z][a-z\\d]*$/;\n\nconst SINGULARS = new LRUCache<string, string>((word: string) => {\n return _singularize(word);\n});\nconst PLURALS = new LRUCache<string, string>((word: string) => {\n return _pluralize(word);\n});\nconst UNCOUNTABLE = new Set(defaultRules.uncountable);\nconst IRREGULAR: Map<string, string> = new Map();\nconst INVERSE_IRREGULAR: Map<string, string> = new Map();\nconst SINGULAR_RULES = new Map(defaultRules.singular.reverse());\nconst PLURAL_RULES = new Map(defaultRules.plurals.reverse());\n\n/**\n * Marks a word as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @since 4.13.0\n */\nexport function uncountable(word: string): void {\n UNCOUNTABLE.add(word.toLowerCase());\n}\n\n/**\n * Marks a list of words as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @public\n * @since 4.13.0\n */\nexport function loadUncountable(uncountables: string[]): void {\n uncountables.forEach((word) => {\n uncountable(word);\n });\n}\n\n/**\n * Marks a word as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @since 4.13.0\n */\nexport function irregular(single: string, plur: string): void {\n //pluralizing\n IRREGULAR.set(single.toLowerCase(), plur);\n IRREGULAR.set(plur.toLowerCase(), plur);\n\n //singularizing\n INVERSE_IRREGULAR.set(plur.toLowerCase(), single);\n INVERSE_IRREGULAR.set(single.toLowerCase(), single);\n}\n\n/**\n * Marks a list of word pairs as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @public\n * @since 4.13.0\n */\nexport function loadIrregular(irregularPairs: Array<[string, string]>): void {\n irregularPairs.forEach((pair) => {\n //pluralizing\n IRREGULAR.set(pair[0].toLowerCase(), pair[1]);\n IRREGULAR.set(pair[1].toLowerCase(), pair[1]);\n\n //singularizing\n INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);\n INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);\n });\n}\nloadIrregular(defaultRules.irregularPairs);\n\n/**\n * Clears the caches for singularize and pluralize.\n *\n * @public\n * @since 4.13.0\n */\nexport function clear(): void {\n SINGULARS.clear();\n PLURALS.clear();\n}\n\n/**\n * Resets the inflection rules to the defaults.\n *\n * @public\n * @since 4.13.0\n */\nexport function resetToDefaults(): void {\n clearRules();\n defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));\n defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));\n defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));\n loadIrregular(defaultRules.irregularPairs);\n}\n\n/**\n * Clears all inflection rules\n * and resets the caches for singularize and pluralize.\n *\n * @public\n * @since 4.13.0\n */\nexport function clearRules(): void {\n SINGULARS.clear();\n PLURALS.clear();\n UNCOUNTABLE.clear();\n IRREGULAR.clear();\n INVERSE_IRREGULAR.clear();\n SINGULAR_RULES.clear();\n PLURAL_RULES.clear();\n}\n\n/**\n * Singularizes a word.\n *\n * @public\n * @since 4.13.0\n */\nexport function singularize(word: string): string {\n assert(`singularize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return SINGULARS.get(word);\n}\n\n/**\n * Pluralizes a word.\n *\n * @public\n * @since 4.13.0\n */\nexport function pluralize(word: string): string {\n assert(`pluralize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return PLURALS.get(word);\n}\n\nfunction unshiftMap<K, V>(v: [K, V], map: Map<K, V>) {\n // reorder\n const rules = [v, ...map.entries()];\n map.clear();\n rules.forEach((rule) => {\n map.set(rule[0], rule[1]);\n });\n}\n\n/**\n * Adds a pluralization rule.\n *\n * @public\n * @since 4.13.0\n */\nexport function plural(regex: RegExp, string: string): void {\n // rule requires reordering if exists, so remove it first\n if (PLURAL_RULES.has(regex)) {\n PLURAL_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], PLURAL_RULES);\n}\n\n/**\n * Adds a singularization rule.\n *\n * @public\n * @since 4.13.0\n */\nexport function singular(regex: RegExp, string: string): void {\n // rule requires reordering if exists, so remove it first\n if (SINGULAR_RULES.has(regex)) {\n SINGULAR_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], SINGULAR_RULES);\n}\n\nfunction _pluralize(word: string) {\n return inflect(word, PLURAL_RULES, IRREGULAR);\n}\n\nfunction _singularize(word: string) {\n return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);\n}\n\nfunction inflect(word: string, typeRules: Map<RegExp, string>, irregulars: Map<string, string>) {\n // empty strings\n const isBlank = !word || BLANK_REGEX.test(word);\n if (isBlank) {\n return word;\n }\n\n // basic uncountables\n const lowercase = word.toLowerCase();\n if (UNCOUNTABLE.has(lowercase)) {\n return word;\n }\n\n // adv uncountables\n const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);\n const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;\n if (lastWord && UNCOUNTABLE.has(lastWord)) {\n return word;\n }\n\n // handle irregulars\n const isCamelized = CAMELIZED_REGEX.test(word);\n for (let [rule, substitution] of irregulars) {\n if (lowercase.match(rule + '$')) {\n if (isCamelized && lastWord && irregulars.has(lastWord)) {\n substitution = capitalize(substitution);\n rule = capitalize(rule);\n }\n\n return word.replace(new RegExp(rule, 'i'), substitution);\n }\n }\n\n // do the actual inflection\n for (const [rule, substitution] of typeRules) {\n if (rule.test(word)) {\n return word.replace(rule, substitution);\n }\n }\n\n return word;\n}\n"],"x_google_ignoreList":[0],"mappings":";;AAEA,MAAMA,yBAAyB;;;;;;;;;;;;;;;;;;;;;AAsB/B,IAAaC,WAAb,MAA4B;CAU1BC,YAAYC,QAAqBC,MAAe;EAC9C,KAAKA,OAAOA,QAAQJ;EACpB,KAAKK,wBAAQ,IAAIC,IAAI;EACrB,KAAKH,SAASA;CAOhB;CAEAI,IAAIC,KAAW;EACb,MAAMC,QAAQ,KAAKJ,MAAME,IAAIC,GAAG;EAChC,IAAIC,OAAO;GAIT,KAAKJ,MAAMK,OAAOF,GAAG;GACrB,KAAKH,MAAMM,IAAIH,KAAKC,KAAK;GACzB,OAAOA;EACT;EAKA,MAAMG,WAAW,KAAKT,OAAOK,GAAG;EAChC,KAAKG,IAAIH,KAAKI,QAAQ;EACtB,OAAOA;CACT;CAEAD,IAAIH,KAAQC,OAAgB;EAC1B,IAAI,KAAKJ,MAAMD,SAAS,KAAKA,MAC3B,KAAK,MAAM,CAACS,MAAM,KAAKR,OAAO;GAI5B,KAAKA,MAAMK,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C7C,KAAK,IAAI,CAACsC,MAAMgB,iBAAiBR,YAC/B,IAAIG,UAAUM,MAAMjB,OAAO,GAAG,GAAG;EAC/B,IAAIe,eAAeD,YAAYN,WAAWJ,IAAIU,QAAQ,GAAG;GACvDE,eAAe5D,WAAW4D,YAAY;GACtChB,OAAO5C,WAAW4C,IAAI;EACxB;EAEA,OAAOtC,KAAKwD,QAAQ,IAAIC,OAAOnB,MAAM,GAAG,GAAGgB,YAAY;CACzD;CAIF,KAAK,MAAM,CAAChB,MAAMgB,iBAAiBT,WACjC,IAAIP,KAAKU,KAAKhD,IAAI,GAChB,OAAOA,KAAKwD,QAAQlB,MAAMgB,YAAY;CAI1C,OAAOtD;AACT"}
@@ -1 +1,12 @@
1
- export { defaultRules as InflectionRuleDefaults } from "./-private/string/inflections.js";
1
+ //#region src/-private/string/inflections.d.ts
2
+ type RulesArray = Array<[RegExp, string]>;
3
+ type DefaultRulesType = {
4
+ plurals: RulesArray;
5
+ singular: RulesArray;
6
+ irregularPairs: Array<[string, string]>;
7
+ uncountable: string[];
8
+ };
9
+ declare const defaultRules: DefaultRulesType;
10
+ //#endregion
11
+ export { defaultRules as InflectionRuleDefaults };
12
+ //# sourceMappingURL=-private.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"-private.d.ts","names":[],"sources":["../src/-private/string/inflections.ts"],"mappings":";KAAY,aAAa,OAAO;KAC3B;EACH,SAAS;EACT,UAAU;EACV,gBAAgB;EAChB;;cAGW,cAAc"}
@@ -1,3 +1,260 @@
1
- export { findRecord } from "./-private/active-record/find-record.js";
2
- export { query } from "./-private/active-record/query.js";
3
- export { deleteRecord, createRecord, updateRecord } from "./-private/active-record/save-record.js";
1
+ import { ReactiveDataDocument } from "@warp-drive/core/reactive";
2
+ import { TypeFromInstance, TypedRecordInstance } from "@warp-drive/core/types/record";
3
+ import { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, FindRecordOptions, FindRecordRequestOptions, QueryRequestOptions, RemotelyAccessibleIdentifier, UpdateRequestOptions } from "@warp-drive/core/types/request";
4
+ import { QueryParamsSource } from "@warp-drive/core/types/params";
5
+ //#region src/-private/active-record/find-record.d.ts
6
+ /**
7
+ * Builds request options to fetch a single resource by a known id or identifier
8
+ * configured for the url and header expectations of most ActiveRecord APIs.
9
+ *
10
+ * **Basic Usage**
11
+ *
12
+ * ```ts
13
+ * import { findRecord } from '@warp-drive/utilities/active-record';
14
+ *
15
+ * const data = await store.request(findRecord('person', '1'));
16
+ * ```
17
+ *
18
+ * **With Options**
19
+ *
20
+ * ```ts
21
+ * import { findRecord } from '@warp-drive/utilities/active-record';
22
+ *
23
+ * const options = findRecord('person', '1', { include: ['pets', 'friends'] });
24
+ * const data = await store.request(options);
25
+ * ```
26
+ *
27
+ * **With an Identifier**
28
+ *
29
+ * ```ts
30
+ * import { findRecord } from '@warp-drive/utilities/active-record';
31
+ *
32
+ * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
33
+ * const data = await store.request(options);
34
+ * ```
35
+ *
36
+ * **Supplying Options to Modify the Request Behavior**
37
+ *
38
+ * The following options are supported:
39
+ *
40
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
41
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
42
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
43
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
44
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
45
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
46
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
47
+ * defaulting to `false` if none is configured.
48
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
49
+ *
50
+ * ```ts
51
+ * import { findRecord } from '@warp-drive/utilities/active-record';
52
+ *
53
+ * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
54
+ * const data = await store.request(options);
55
+ * ```
56
+ *
57
+ * @public
58
+ * @param identifier
59
+ * @param options
60
+ */
61
+ declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
62
+ declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
63
+ declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
64
+ declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
65
+ //#endregion
66
+ //#region src/-private/active-record/query.d.ts
67
+ /**
68
+ * Builds request options to query for resources, usually by a primary
69
+ * type, configured for the url and header expectations of most ActiveRecord APIs.
70
+ *
71
+ * **Basic Usage**
72
+ *
73
+ * ```ts
74
+ * import { query } from '@warp-drive/utilities/active-record';
75
+ *
76
+ * const data = await store.request(query('person'));
77
+ * ```
78
+ *
79
+ * **With Query Params**
80
+ *
81
+ * ```ts
82
+ * import { query } from '@warp-drive/utilities/active-record';
83
+ *
84
+ * const options = query('person', { include: ['pets', 'friends'] });
85
+ * const data = await store.request(options);
86
+ * ```
87
+ *
88
+ * **Supplying Options to Modify the Request Behavior**
89
+ *
90
+ * The following options are supported:
91
+ *
92
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
93
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
94
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
95
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
96
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
97
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
98
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
99
+ * defaulting to `false` if none is configured.
100
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
101
+ *
102
+ * ```ts
103
+ * import { query } from '@warp-drive/utilities/active-record';
104
+ *
105
+ * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
106
+ * const data = await store.request(options);
107
+ * ```
108
+ *
109
+ * @public
110
+ * @param identifier
111
+ * @param query
112
+ * @param options
113
+ */
114
+ declare function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<ReactiveDataDocument<T[]>>;
115
+ declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
116
+ //#endregion
117
+ //#region src/-private/active-record/save-record.d.ts
118
+ /**
119
+ * Builds request options to delete record for resources,
120
+ * configured for the url, method and header expectations of ActiveRecord APIs.
121
+ *
122
+ * **Basic Usage**
123
+ *
124
+ * ```ts
125
+ * import { deleteRecord } from '@warp-drive/utilities/active-record';
126
+ *
127
+ * const person = store.peekRecord('person', '1');
128
+ *
129
+ * // mark record as deleted
130
+ * store.deleteRecord(person);
131
+ *
132
+ * // persist deletion
133
+ * const data = await store.request(deleteRecord(person));
134
+ * ```
135
+ *
136
+ * **Supplying Options to Modify the Request Behavior**
137
+ *
138
+ * The following options are supported:
139
+ *
140
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
141
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
142
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
143
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
144
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
145
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
146
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
147
+ * defaulting to `false` if none is configured.
148
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
149
+ *
150
+ * ```ts
151
+ * import { deleteRecord } from '@warp-drive/utilities/active-record';
152
+ *
153
+ * const person = store.peekRecord('person', '1');
154
+ *
155
+ * // mark record as deleted
156
+ * store.deleteRecord(person);
157
+ *
158
+ * // persist deletion
159
+ * const options = deleteRecord(person, { namespace: 'api/v1' });
160
+ * const data = await store.request(options);
161
+ * ```
162
+ *
163
+ * @public
164
+ * @param record
165
+ * @param options
166
+ */
167
+ declare function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
168
+ declare function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
169
+ /**
170
+ * Builds request options to create new record for resources,
171
+ * configured for the url, method and header expectations of most ActiveRecord APIs.
172
+ *
173
+ * **Basic Usage**
174
+ *
175
+ * ```ts
176
+ * import { createRecord } from '@warp-drive/utilities/active-record';
177
+ *
178
+ * const person = store.createRecord('person', { name: 'Ted' });
179
+ * const data = await store.request(createRecord(person));
180
+ * ```
181
+ *
182
+ * **Supplying Options to Modify the Request Behavior**
183
+ *
184
+ * The following options are supported:
185
+ *
186
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
187
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
188
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
189
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
190
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
191
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
192
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
193
+ * defaulting to `false` if none is configured.
194
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
195
+ *
196
+ * ```ts
197
+ * import { createRecord } from '@warp-drive/utilities/active-record';
198
+ *
199
+ * const person = store.createRecord('person', { name: 'Ted' });
200
+ * const options = createRecord(person, { namespace: 'api/v1' });
201
+ * const data = await store.request(options);
202
+ * ```
203
+ *
204
+ * @public
205
+ * @param record
206
+ * @param options
207
+ */
208
+ declare function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
209
+ declare function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
210
+ /**
211
+ * Builds request options to update existing record for resources,
212
+ * configured for the url, method and header expectations of most ActiveRecord APIs.
213
+ *
214
+ * **Basic Usage**
215
+ *
216
+ * ```ts
217
+ * import { updateRecord } from '@warp-drive/utilities/active-record';
218
+ *
219
+ * const person = store.peekRecord('person', '1');
220
+ * person.name = 'Chris';
221
+ * const data = await store.request(updateRecord(person));
222
+ * ```
223
+ *
224
+ * **Supplying Options to Modify the Request Behavior**
225
+ *
226
+ * The following options are supported:
227
+ *
228
+ * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
229
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
230
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
231
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
232
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
233
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
234
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
235
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
236
+ * defaulting to `false` if none is configured.
237
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
238
+ *
239
+ * ```ts
240
+ * import { updateRecord } from '@warp-drive/utilities/active-record';
241
+ *
242
+ * const person = store.peekRecord('person', '1');
243
+ * person.name = 'Chris';
244
+ * const options = updateRecord(person, { patch: true });
245
+ * const data = await store.request(options);
246
+ * ```
247
+ *
248
+ * @public
249
+ * @param record
250
+ * @param options
251
+ */
252
+ declare function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(record: T, options?: ConstrainedRequestOptions & {
253
+ patch?: boolean;
254
+ }): UpdateRequestOptions<ReactiveDataDocument<RT>, T>;
255
+ declare function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
256
+ patch?: boolean;
257
+ }): UpdateRequestOptions;
258
+ //#endregion
259
+ export { createRecord, deleteRecord, findRecord, query, updateRecord };
260
+ //# sourceMappingURL=active-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-record.d.ts","names":[],"sources":["../src/-private/active-record/find-record.ts","../src/-private/active-record/query.ts","../src/-private/active-record/save-record.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmEgB,WAAW,GACzB,YAAY,6BAA6B,iBAAiB,KAC1D,UAAU,oBACT,yBAAyB,qBAAqB,IAAI;iBACrC,WACd,YAAY,8BACZ,UAAU,oBACT;iBACa,WAAW,GACzB,MAAM,iBAAiB,IACvB,YACA,UAAU,oBACT,yBAAyB,qBAAqB,IAAI;iBACrC,WAAW,cAAc,YAAY,UAAU,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCxBnE,MAAM,GACpB,MAAM,iBAAiB,IACvB,QAAQ,mBACR,UAAU,4BACT,oBAAoB,qBAAqB;iBAC5B,MACd,cACA,QAAQ,mBACR,UAAU,4BACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCSa,aAAa,GAAG,QAAQ,GAAG,UAAU,4BAA4B,qBAAqB;iBACtF,aAAa,iBAAiB,UAAU,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqEpE,aAAa,GAAG,QAAQ,GAAG,UAAU,4BAA4B,qBAAqB;iBACtF,aAAa,iBAAiB,UAAU,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuEpE,aAAa,UAAU,qBAAqB,WAAW,sBAAsB,GAC3F,QAAQ,GACR,UAAU;EAA8B;IACvC,qBAAqB,qBAAqB,KAAK;iBAClC,aACd,iBACA,UAAU;EAA8B;IACvC"}
@@ -1,27 +1,30 @@
1
- import type { ReactiveResource } from "@warp-drive/core/reactive";
2
1
  import { Type } from "@warp-drive/core/types/symbols";
2
+ import { ReactiveResource } from "@warp-drive/core/reactive";
3
+ //#region src/derivations.d.ts
3
4
  interface ConcatDerivation {
4
- (record: ReactiveResource & {
5
- [key: string]: unknown;
6
- }, options: Record<string, unknown> | null, _prop: string): string;
7
- [Type]: "concat";
5
+ (record: ReactiveResource & {
6
+ [key: string]: unknown;
7
+ }, options: Record<string, unknown> | null, _prop: string): string;
8
+ [Type]: "concat";
8
9
  }
9
10
  /**
10
- * A derivation for use by {@link ReactiveResource} that joins the given fields
11
- * with the optional separator (or '' if no separator is provided).
12
- *
13
- * Generally you should not need to import and use this function directly.
14
- *
15
- * @example
16
- * {
17
- * name: 'fullName',
18
- * kind: 'derived',
19
- * type: 'concat',
20
- * options: {
21
- * fields: ['firstName', 'lastName'],
22
- * separator: ' ',
23
- * },
24
- * }
25
- */
26
- export declare const concat: ConcatDerivation;
27
- export {};
11
+ * A derivation for use by {@link ReactiveResource} that joins the given fields
12
+ * with the optional separator (or '' if no separator is provided).
13
+ *
14
+ * Generally you should not need to import and use this function directly.
15
+ *
16
+ * @example
17
+ * {
18
+ * name: 'fullName',
19
+ * kind: 'derived',
20
+ * type: 'concat',
21
+ * options: {
22
+ * fields: ['firstName', 'lastName'],
23
+ * separator: ' ',
24
+ * },
25
+ * }
26
+ */
27
+ declare const concat: ConcatDerivation;
28
+ //#endregion
29
+ export { concat };
30
+ //# sourceMappingURL=derivations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derivations.d.ts","names":[],"sources":["../src/derivations.ts"],"mappings":";;;UAGU;GAEN,QAAQ;;KACR,SAAS,gCACT;GAED;;;;;;;;;;;;;;;;;;;cAoBU,QAAQ"}