velocious 1.0.700 → 1.0.702

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 (56) hide show
  1. package/README.md +1 -0
  2. package/build/configuration-types.js +73 -3
  3. package/build/configuration.js +113 -20
  4. package/build/frontend-model-resource/base-resource.js +150 -2
  5. package/build/frontend-models/resource-definition.js +47 -0
  6. package/build/src/configuration-types.d.ts +168 -7
  7. package/build/src/configuration-types.d.ts.map +1 -1
  8. package/build/src/configuration-types.js +68 -4
  9. package/build/src/configuration.d.ts +22 -2
  10. package/build/src/configuration.d.ts.map +1 -1
  11. package/build/src/configuration.js +110 -20
  12. package/build/src/frontend-model-resource/base-resource.d.ts +76 -3
  13. package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
  14. package/build/src/frontend-model-resource/base-resource.js +127 -3
  15. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  16. package/build/src/frontend-models/resource-definition.js +43 -1
  17. package/build/src/sync/local-mutation-log.d.ts +6 -3
  18. package/build/src/sync/local-mutation-log.d.ts.map +1 -1
  19. package/build/src/sync/local-mutation-log.js +11 -4
  20. package/build/src/sync/peer-mutation-bundle.d.ts +26 -0
  21. package/build/src/sync/peer-mutation-bundle.d.ts.map +1 -1
  22. package/build/src/sync/peer-mutation-bundle.js +7 -1
  23. package/build/src/sync/sync-api-client.d.ts +3 -1
  24. package/build/src/sync/sync-api-client.d.ts.map +1 -1
  25. package/build/src/sync/sync-api-client.js +46 -8
  26. package/build/src/sync/sync-client-types.d.ts +24 -12
  27. package/build/src/sync/sync-client-types.d.ts.map +1 -1
  28. package/build/src/sync/sync-client-types.js +7 -5
  29. package/build/src/sync/sync-client.d.ts +101 -0
  30. package/build/src/sync/sync-client.d.ts.map +1 -1
  31. package/build/src/sync/sync-client.js +236 -24
  32. package/build/src/sync/sync-offline-session.d.ts +328 -0
  33. package/build/src/sync/sync-offline-session.d.ts.map +1 -0
  34. package/build/src/sync/sync-offline-session.js +617 -0
  35. package/build/src/sync/sync-resource-base.d.ts +26 -28
  36. package/build/src/sync/sync-resource-base.d.ts.map +1 -1
  37. package/build/src/sync/sync-resource-base.js +11 -45
  38. package/build/sync/local-mutation-log.js +10 -3
  39. package/build/sync/peer-mutation-bundle.js +6 -0
  40. package/build/sync/sync-api-client.js +53 -7
  41. package/build/sync/sync-client-types.js +6 -4
  42. package/build/sync/sync-client.js +264 -21
  43. package/build/sync/sync-offline-session.js +713 -0
  44. package/build/sync/sync-resource-base.js +10 -53
  45. package/package.json +1 -1
  46. package/src/configuration-types.js +73 -3
  47. package/src/configuration.js +113 -20
  48. package/src/frontend-model-resource/base-resource.js +150 -2
  49. package/src/frontend-models/resource-definition.js +47 -0
  50. package/src/sync/local-mutation-log.js +10 -3
  51. package/src/sync/peer-mutation-bundle.js +6 -0
  52. package/src/sync/sync-api-client.js +53 -7
  53. package/src/sync/sync-client-types.js +6 -4
  54. package/src/sync/sync-client.js +264 -21
  55. package/src/sync/sync-offline-session.js +713 -0
  56. package/src/sync/sync-resource-base.js +10 -53
@@ -6,7 +6,6 @@ import FrontendModelBaseResource from "../frontend-model-resource/base-resource.
6
6
  import SyncEnvelopeReplayService from "./sync-envelope-replay-service.js"
7
7
  import SyncModelChangeFeedService from "./sync-model-change-feed-service.js"
8
8
  import {syncUpstreamImporterForConfiguration} from "./sync-upstream-importer.js"
9
- import VelociousError from "../velocious-error.js"
10
9
 
11
10
  /**
12
11
  * Optional client-declared sync scope carried on a changes request.
@@ -26,8 +25,6 @@ import VelociousError from "../velocious-error.js"
26
25
  * `resourceId`/`resourceType` keep working unchanged.
27
26
  * @typedef {Record<string, ReturnType<typeof JSON.parse>> & {resourceId: string, resourceType: string}} ChangeDeliverableSyncEntry
28
27
  */
29
- const QUICK_SEARCH_COLUMN = "quickSearch"
30
-
31
28
  /**
32
29
  * Base resource for Velocious sync endpoints.
33
30
  *
@@ -49,61 +46,21 @@ export default class SyncResourceBase extends FrontendModelBaseResource {
49
46
  static ReplayServiceClass = undefined
50
47
 
51
48
  /**
52
- * Declarative quick-search text columns. When declared, an index search on
53
- * the pseudo-column `quickSearch` expands to an OR of LIKE conditions over
54
- * these root-table columns instead of hitting the controller default.
55
- * @type {string[] | null} */
56
- static quickSearchColumns = null
57
-
58
- /**
59
- * Applies frontend-model index searches, expanding declared quick searches.
60
- * @param {object} args - Search args.
61
- * @param {import("../frontend-model-resource/base-resource.js").FrontendModelResourceController} args.controller - Controller handling the query.
62
- * @param {import("../frontend-model-resource/base-resource.js").FrontendModelResourceAnyQuery} args.query - Query instance.
63
- * @param {import("../frontend-model-resource/base-resource.js").FrontendModelResourceSearch} args.search - Search params.
64
- * @returns {void}
49
+ * Keeps the sync resource's established public error contract for invalid
50
+ * quick-search payloads; the quick-search mechanism itself lives on
51
+ * FrontendModelBaseResource.
52
+ * @returns {string} - Error label.
65
53
  */
66
- applyFrontendModelIndexSearch({controller, query, search}) {
67
- if (this.applyQuickSearch({query, search})) return
68
-
69
- super.applyFrontendModelIndexSearch({controller, query, search})
54
+ quickSearchErrorLabel() {
55
+ return "Sync quick search"
70
56
  }
71
57
 
72
58
  /**
73
- * Expands a `quickSearch` pseudo-column search into an OR of LIKE conditions
74
- * over the declared {@link SyncResourceBase.quickSearchColumns}.
75
- * @param {object} args - Search args.
76
- * @param {import("../frontend-model-resource/base-resource.js").FrontendModelResourceAnyQuery} args.query - Query to filter.
77
- * @param {import("../frontend-model-resource/base-resource.js").FrontendModelResourceSearch} args.search - Search payload.
78
- * @returns {boolean} Whether the search was handled as a quick search.
59
+ * Keeps the established public error code for invalid quick-search payloads.
60
+ * @returns {string} - Error code.
79
61
  */
80
- applyQuickSearch({query, search}) {
81
- const quickSearchColumns = /** @type {typeof SyncResourceBase} */ (this.constructor).quickSearchColumns
82
-
83
- if (!quickSearchColumns || quickSearchColumns.length === 0) return false
84
- if (search.path.length > 0 || search.column !== QUICK_SEARCH_COLUMN) return false
85
-
86
- if (search.operator !== "like") {
87
- throw VelociousError.safe("Sync quick search must use the like operator.", {code: "sync-invalid-quick-search"})
88
- }
89
-
90
- if (typeof search.value !== "string") {
91
- throw VelociousError.safe("Sync quick search must be a string.", {code: "sync-invalid-quick-search"})
92
- }
93
-
94
- const trimmedValue = search.value.trim()
95
-
96
- if (!trimmedValue) return true
97
-
98
- const tableSql = query.driver.quoteTable(query.getTableReferenceForJoin())
99
- const likeValue = `%${trimmedValue}%`
100
- const conditions = quickSearchColumns.map((columnName) => (
101
- `${tableSql}.${query.driver.quoteColumn(columnName)} LIKE ${query.driver.quote(likeValue)}`
102
- ))
103
-
104
- query.where(`(${conditions.join(" OR ")})`)
105
-
106
- return true
62
+ quickSearchErrorCode() {
63
+ return "sync-invalid-quick-search"
107
64
  }
108
65
 
109
66
  // The declarative `static writableAttributes` permit list lives on