@warp-drive/utilities 5.7.0-alpha.0 → 5.7.0-alpha.10

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.
@@ -59,7 +59,7 @@ export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "d
59
59
  * @param identifier
60
60
  * @param options
61
61
  */
62
- export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
62
+ export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
63
63
  export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
64
- export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
64
+ export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
65
65
  export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
@@ -59,7 +59,7 @@ import type { SingleResourceDataDocument } from "@warp-drive/core/types/spec/doc
59
59
  export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "data"> & {
60
60
  data: T;
61
61
  };
62
- export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
62
+ export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
63
63
  export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
64
- export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
64
+ export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
65
65
  export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
@@ -53,7 +53,7 @@ import type { CollectionResourceDataDocument } from "@warp-drive/core/types/spec
53
53
  * @param query
54
54
  * @param options
55
55
  */
56
- export declare function query<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query?: QueryParamsSource<T>, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;
56
+ export declare function query<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;
57
57
  export declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
58
58
  /**
59
59
  * Builds request options to query for resources, usually by a primary
@@ -59,7 +59,7 @@ import type { SingleResourceDataDocument } from "@warp-drive/core/types/spec/doc
59
59
  export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "data"> & {
60
60
  data: T;
61
61
  };
62
- export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
62
+ export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
63
63
  export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
64
- export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
64
+ export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
65
65
  export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
@@ -0,0 +1,27 @@
1
+ import type { ReactiveResource } from "@warp-drive/core/reactive";
2
+ import { Type } from "@warp-drive/core/types/symbols";
3
+ interface ConcatDerivation {
4
+ (record: ReactiveResource & {
5
+ [key: string]: unknown;
6
+ }, options: Record<string, unknown> | null, _prop: string): string;
7
+ [Type]: "concat";
8
+ }
9
+ /**
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 {};
@@ -0,0 +1,30 @@
1
+ import { Type } from '@warp-drive/core/types/symbols';
2
+
3
+ /**
4
+ * A derivation for use by {@link ReactiveResource} that joins the given fields
5
+ * with the optional separator (or '' if no separator is provided).
6
+ *
7
+ * Generally you should not need to import and use this function directly.
8
+ *
9
+ * @example
10
+ * {
11
+ * name: 'fullName',
12
+ * kind: 'derived',
13
+ * type: 'concat',
14
+ * options: {
15
+ * fields: ['firstName', 'lastName'],
16
+ * separator: ' ',
17
+ * },
18
+ * }
19
+ */
20
+ const concat = (record, options, _prop) => {
21
+ if (!options) {
22
+ throw new Error(`options is required`);
23
+ }
24
+ // SAFETY: we cast internally to a more specific type, for our own use
25
+ // SAFETY: but provide the more general signature to the schema service
26
+ const opts = options;
27
+ return opts.fields.map(field => record[field]).join(opts.separator ?? '');
28
+ };
29
+ concat[Type] = 'concat';
30
+ export { concat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warp-drive/utilities",
3
- "version": "5.7.0-alpha.0",
3
+ "version": "5.7.0-alpha.10",
4
4
  "description": "Utilities package for WarpDrive | Things your app might find useful",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -36,7 +36,7 @@
36
36
  }
37
37
  },
38
38
  "peerDependencies": {
39
- "@warp-drive/core": "5.7.0-alpha.0"
39
+ "@warp-drive/core": "5.7.0-alpha.10"
40
40
  },
41
41
  "dependencies": {
42
42
  "@embroider/macros": "^1.16.12"
@@ -45,8 +45,8 @@
45
45
  "@babel/core": "^7.26.10",
46
46
  "@babel/plugin-transform-typescript": "^7.27.0",
47
47
  "@babel/preset-typescript": "^7.27.0",
48
- "@warp-drive/internal-config": "5.7.0-alpha.0",
49
- "@warp-drive/core": "5.7.0-alpha.0",
48
+ "@warp-drive/internal-config": "5.7.0-alpha.10",
49
+ "@warp-drive/core": "5.7.0-alpha.10",
50
50
  "decorator-transforms": "^2.3.0",
51
51
  "expect-type": "^1.2.1",
52
52
  "typescript": "^5.8.3",