@fjell/client-api 4.4.4 → 4.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AItemAPI.js.map +1 -1
- package/dist/Utilities.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/ops/action.js.map +1 -1
- package/dist/ops/all.js.map +1 -1
- package/dist/ops/allAction.js.map +1 -1
- package/dist/ops/allFacet.js.map +1 -1
- package/dist/ops/create.js.map +1 -1
- package/dist/ops/facet.js.map +1 -1
- package/dist/ops/find.js.map +1 -1
- package/dist/ops/findOne.js.map +1 -1
- package/dist/ops/get.js.map +1 -1
- package/dist/ops/one.js.map +1 -1
- package/dist/ops/remove.js.map +1 -1
- package/dist/ops/update.js.map +1 -1
- package/package.json +16 -16
- package/.kodrdriv/config.yaml +0 -14
- package/.kodrdriv/context/content.md +0 -1
- package/babel.config.cjs +0 -14
- package/commit.sh +0 -8
- package/release.sh +0 -89
- package/src/AItemAPI.ts +0 -95
- package/src/CItemAPI.ts +0 -107
- package/src/ClientApi.ts +0 -64
- package/src/ClientApiOptions.ts +0 -22
- package/src/PItemAPI.ts +0 -181
- package/src/Utilities.ts +0 -183
- package/src/index.ts +0 -7
- package/src/logger.ts +0 -5
- package/src/ops/action.ts +0 -48
- package/src/ops/all.ts +0 -50
- package/src/ops/allAction.ts +0 -50
- package/src/ops/allFacet.ts +0 -46
- package/src/ops/create.ts +0 -47
- package/src/ops/facet.ts +0 -58
- package/src/ops/find.ts +0 -49
- package/src/ops/findOne.ts +0 -51
- package/src/ops/get.ts +0 -42
- package/src/ops/index.ts +0 -96
- package/src/ops/one.ts +0 -61
- package/src/ops/remove.ts +0 -38
- package/src/ops/update.ts +0 -44
- package/src/util/general.ts +0 -65
package/dist/ops/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sources":["../../src/ops/update.ts"],"sourcesContent":["import {\n ComKey,\n Item,\n PriKey\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"@/ClientApiOptions\";\nimport LibLogger from \"@/logger\";\nimport { Utilities } from \"@/Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'update');\n\nexport const getUpdateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ) => {\n\n const update = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('update', { ik, item, requestOptions });\n\n return utilities.validatePK(await utilities.processOne(\n api.httpPut<V>(\n utilities.getPath(ik),\n item,\n requestOptions,\n ))) as V;\n }\n\n return update;\n}\n"],"names":["logger","LibLogger","get","getUpdateOperation","api","apiOptions","utilities","update","ik","item","requestOptions","Object","assign","putOptions","isAuthenticated","writeAuthenticated","default","validatePK","processOne","httpPut","getPath"],"mappings":";;AAWA,MAAMA,MAAAA,GAASC,SAAAA,CAAUC,GAAG,CAAC,cAAc,KAAA,EAAO,QAAA,CAAA;AAE3C,MAAMC,kBAAAA,GAAqB,CAQ9BC,GAAAA,EACAC,UAAAA,EACAC,SAAAA,GAAAA;IAIF,MAAMC,MAAAA,GAAS,OACbC,EAAAA,EACAC,IAAAA,GAAAA;QAEA,MAAMC,cAAAA,GAAiBC,OAAOC,MAAM,CAAC,EAAC,EAAGP,UAAAA,CAAWQ,UAAU,EAAE;AAAEC,YAAAA,eAAAA,EAAiBT,WAAWU;AAAmB,SAAA,CAAA;QACjHf,MAAAA,CAAOgB,OAAO,CAAC,QAAA,EAAU;AAAER,YAAAA,EAAAA;AAAIC,YAAAA,IAAAA;AAAMC,YAAAA;AAAe,SAAA,CAAA;AAEpD,QAAA,OAAOJ,SAAAA,CAAUW,UAAU,CAAC,MAAMX,UAAUY,UAAU,CACpDd,GAAAA,CAAIe,OAAO,CACTb,SAAAA,CAAUc,OAAO,CAACZ,KAClBC,IAAAA,EACAC,cAAAA,CAAAA,CAAAA,CAAAA;AAEN,
|
|
1
|
+
{"version":3,"file":"update.js","sources":["../../src/ops/update.ts"],"sourcesContent":["import {\n ComKey,\n Item,\n PriKey\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"@/ClientApiOptions\";\nimport LibLogger from \"@/logger\";\nimport { Utilities } from \"@/Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'update');\n\nexport const getUpdateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ) => {\n\n const update = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('update', { ik, item, requestOptions });\n\n return utilities.validatePK(await utilities.processOne(\n api.httpPut<V>(\n utilities.getPath(ik),\n item,\n requestOptions,\n ))) as V;\n }\n\n return update;\n}\n"],"names":["logger","LibLogger","get","getUpdateOperation","api","apiOptions","utilities","update","ik","item","requestOptions","Object","assign","putOptions","isAuthenticated","writeAuthenticated","default","validatePK","processOne","httpPut","getPath"],"mappings":";;AAWA,MAAMA,MAAAA,GAASC,SAAAA,CAAUC,GAAG,CAAC,cAAc,KAAA,EAAO,QAAA,CAAA;AAE3C,MAAMC,kBAAAA,GAAqB,CAQ9BC,GAAAA,EACAC,UAAAA,EACAC,SAAAA,GAAAA;IAIF,MAAMC,MAAAA,GAAS,OACbC,EAAAA,EACAC,IAAAA,GAAAA;QAEA,MAAMC,cAAAA,GAAiBC,OAAOC,MAAM,CAAC,EAAC,EAAGP,UAAAA,CAAWQ,UAAU,EAAE;AAAEC,YAAAA,eAAAA,EAAiBT,WAAWU;AAAmB,SAAA,CAAA;QACjHf,MAAAA,CAAOgB,OAAO,CAAC,QAAA,EAAU;AAAER,YAAAA,EAAAA;AAAIC,YAAAA,IAAAA;AAAMC,YAAAA;AAAe,SAAA,CAAA;AAEpD,QAAA,OAAOJ,SAAAA,CAAUW,UAAU,CAAC,MAAMX,UAAUY,UAAU,CACpDd,GAAAA,CAAIe,OAAO,CACTb,SAAAA,CAAUc,OAAO,CAACZ,KAClBC,IAAAA,EACAC,cAAAA,CAAAA,CAAAA,CAAAA;AAEN,IAAA,CAAA;IAEA,OAAOH,MAAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/client-api",
|
|
3
3
|
"description": "Client API for Fjell",
|
|
4
|
-
"version": "4.4.
|
|
4
|
+
"version": "4.4.6",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"client",
|
|
7
|
+
"api",
|
|
8
|
+
"fjell"
|
|
9
|
+
],
|
|
5
10
|
"license": "Apache-2.0",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"module": "./dist/index.js",
|
|
@@ -12,33 +17,28 @@
|
|
|
12
17
|
}
|
|
13
18
|
},
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@fjell/core": "^4.4.
|
|
16
|
-
"@fjell/http-api": "^4.4.
|
|
17
|
-
"@fjell/logging": "^4.4.
|
|
20
|
+
"@fjell/core": "^4.4.7",
|
|
21
|
+
"@fjell/http-api": "^4.4.5",
|
|
22
|
+
"@fjell/logging": "^4.4.7",
|
|
18
23
|
"deepmerge": "^4.3.1"
|
|
19
24
|
},
|
|
20
25
|
"devDependencies": {
|
|
21
|
-
"@babel/core": "^7.27.7",
|
|
22
|
-
"@babel/preset-env": "^7.27.2",
|
|
23
|
-
"@babel/preset-typescript": "^7.27.1",
|
|
24
26
|
"@eslint/eslintrc": "^3.3.1",
|
|
25
|
-
"@eslint/js": "^9.
|
|
26
|
-
"@swc/core": "^1.12.
|
|
27
|
+
"@eslint/js": "^9.31.0",
|
|
28
|
+
"@swc/core": "^1.12.14",
|
|
27
29
|
"@tsconfig/recommended": "^1.0.10",
|
|
28
|
-
"@
|
|
29
|
-
"@typescript-eslint/
|
|
30
|
-
"@typescript-eslint/parser": "^8.35.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
31
|
+
"@typescript-eslint/parser": "^8.37.0",
|
|
31
32
|
"@vitest/coverage-istanbul": "^3.2.4",
|
|
32
33
|
"@vitest/coverage-v8": "^3.2.4",
|
|
33
34
|
"@vitest/ui": "^3.2.4",
|
|
34
35
|
"concurrently": "^9.2.0",
|
|
35
|
-
"eslint": "^9.
|
|
36
|
+
"eslint": "^9.31.0",
|
|
36
37
|
"rimraf": "^6.0.1",
|
|
37
|
-
"tsc-alias": "^1.8.16",
|
|
38
38
|
"typescript": "^5.8.3",
|
|
39
|
-
"vite": "^7.0.
|
|
39
|
+
"vite": "^7.0.4",
|
|
40
40
|
"vite-plugin-dts": "^4.5.4",
|
|
41
|
-
"vite-plugin-node": "^
|
|
41
|
+
"vite-plugin-node": "^7.0.0",
|
|
42
42
|
"vitest": "^3.2.4"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
package/.kodrdriv/config.yaml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This the Fjell library that provides a framework for client-side APIs
|
package/babel.config.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
['@babel/preset-env', { targets: { node: 'current' } }],
|
|
4
|
-
'@babel/preset-typescript'
|
|
5
|
-
],
|
|
6
|
-
overrides: [
|
|
7
|
-
{
|
|
8
|
-
test: /node_modules[\\/](?:@fjell[\\/](core|http-api|logging))/,
|
|
9
|
-
presets: [
|
|
10
|
-
['@babel/preset-env', { targets: { node: 'current' } }]
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
};
|
package/commit.sh
DELETED
package/release.sh
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
echo "Preparing for release: switching from workspace to remote dependencies."
|
|
6
|
-
if [ -f "pnpm-workspace.yaml" ]; then
|
|
7
|
-
echo "Renaming pnpm-workspace.yaml to prevent workspace-protocol resolution"
|
|
8
|
-
mv pnpm-workspace.yaml pnpm-workspace.yaml.bak
|
|
9
|
-
else
|
|
10
|
-
echo "pnpm-workspace.yaml not found, skipping rename."
|
|
11
|
-
fi
|
|
12
|
-
|
|
13
|
-
echo "Updating dependencies to latest versions from registry"
|
|
14
|
-
pnpm update --latest
|
|
15
|
-
|
|
16
|
-
echo "Staging changes for release commit"
|
|
17
|
-
git add package.json pnpm-lock.yaml
|
|
18
|
-
|
|
19
|
-
echo "Running clean, lint, build, and test..."
|
|
20
|
-
pnpm run clean && pnpm run lint && pnpm run build && pnpm run test
|
|
21
|
-
|
|
22
|
-
if git diff --staged --quiet; then
|
|
23
|
-
echo "No changes to commit, skipping commit."
|
|
24
|
-
else
|
|
25
|
-
./commit.sh
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
echo "Bumping version..."
|
|
29
|
-
pnpm version patch
|
|
30
|
-
|
|
31
|
-
echo "Generating release notes..."
|
|
32
|
-
pnpm dlx @eldrforge/kodrdriv release > RELEASE_NOTES.md
|
|
33
|
-
|
|
34
|
-
echo "Pushing to origin..."
|
|
35
|
-
git push --follow-tags
|
|
36
|
-
|
|
37
|
-
echo "Creating GitHub pull request..."
|
|
38
|
-
PR_URL=$(gh pr create --fill)
|
|
39
|
-
PR_NUM=$(echo "$PR_URL" | grep -o '[0-9]*$')
|
|
40
|
-
echo "Pull request created: $PR_URL"
|
|
41
|
-
|
|
42
|
-
echo "Waiting for PR #$PR_NUM checks to complete..."
|
|
43
|
-
while true; do
|
|
44
|
-
STATUS=$(gh pr view "$PR_NUM" --json statusCheckRollup --jq '.statusCheckRollup.state' 2>/dev/null)
|
|
45
|
-
if [[ -z "$STATUS" ]]; then
|
|
46
|
-
STATUS="PENDING"
|
|
47
|
-
fi
|
|
48
|
-
echo "PR status: $STATUS"
|
|
49
|
-
if [[ "$STATUS" == "SUCCESS" ]]; then
|
|
50
|
-
echo "All checks passed!"
|
|
51
|
-
break
|
|
52
|
-
elif [[ "$STATUS" == "FAILURE" || "$STATUS" == "ERROR" ]]; then
|
|
53
|
-
echo "PR checks failed."
|
|
54
|
-
gh pr checks "$PR_NUM"
|
|
55
|
-
exit 1
|
|
56
|
-
elif [[ "$STATUS" == "PENDING" || "$STATUS" == "EXPECTED" ]]; then
|
|
57
|
-
echo "Checks are pending... waiting 10 seconds."
|
|
58
|
-
sleep 10
|
|
59
|
-
else
|
|
60
|
-
echo "Unknown PR status: $STATUS. Waiting 10 seconds."
|
|
61
|
-
sleep 10
|
|
62
|
-
fi
|
|
63
|
-
done
|
|
64
|
-
|
|
65
|
-
echo "Merging PR #$PR_NUM..."
|
|
66
|
-
gh pr merge "$PR_NUM" --squash --delete-branch
|
|
67
|
-
|
|
68
|
-
echo "Checking out main branch..."
|
|
69
|
-
git checkout main
|
|
70
|
-
git pull origin main
|
|
71
|
-
|
|
72
|
-
echo "Creating GitHub release..."
|
|
73
|
-
TAG_NAME="v$(jq -r .version package.json)"
|
|
74
|
-
gh release create "$TAG_NAME" --notes-file RELEASE_NOTES.md
|
|
75
|
-
|
|
76
|
-
echo "Creating next release branch..."
|
|
77
|
-
CURRENT_VERSION=$(jq -r .version package.json)
|
|
78
|
-
MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1)
|
|
79
|
-
MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2)
|
|
80
|
-
PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3)
|
|
81
|
-
NEXT_PATCH=$((PATCH + 1))
|
|
82
|
-
NEXT_VERSION="$MAJOR.$MINOR.$NEXT_PATCH"
|
|
83
|
-
|
|
84
|
-
echo "Next version is $NEXT_VERSION"
|
|
85
|
-
git checkout -b "release/v$NEXT_VERSION"
|
|
86
|
-
git commit -m "feat: Start release v$NEXT_VERSION"
|
|
87
|
-
git push -u origin "release/v$NEXT_VERSION"
|
|
88
|
-
|
|
89
|
-
echo "Release process completed."
|
package/src/AItemAPI.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/* eslint-disable indent */
|
|
2
|
-
import { Item, QueryParams } from "@fjell/core";
|
|
3
|
-
import { HttpApi } from "@fjell/http-api";
|
|
4
|
-
|
|
5
|
-
import { ClientApiOptions } from "./ClientApiOptions";
|
|
6
|
-
import { getOperations } from "./ops";
|
|
7
|
-
import { createUtilities } from "./Utilities";
|
|
8
|
-
import { ClientApi } from "./ClientApi";
|
|
9
|
-
|
|
10
|
-
import LibLogger from "@/logger";
|
|
11
|
-
|
|
12
|
-
const logger = LibLogger.get('AItemAPI');
|
|
13
|
-
|
|
14
|
-
export type PathNamesArray<
|
|
15
|
-
L1 extends string = never,
|
|
16
|
-
L2 extends string = never,
|
|
17
|
-
L3 extends string = never,
|
|
18
|
-
L4 extends string = never,
|
|
19
|
-
L5 extends string = never
|
|
20
|
-
> =
|
|
21
|
-
([L5] extends [never] ?
|
|
22
|
-
([L4] extends [never] ?
|
|
23
|
-
([L3] extends [never] ?
|
|
24
|
-
([L2] extends [never] ?
|
|
25
|
-
([L1] extends [never] ?
|
|
26
|
-
[string] :
|
|
27
|
-
[string, string]) :
|
|
28
|
-
[string, string, string]) :
|
|
29
|
-
[string, string, string, string]) :
|
|
30
|
-
[string, string, string, string, string]) :
|
|
31
|
-
[string, string, string, string, string, string]);
|
|
32
|
-
|
|
33
|
-
export const finderToParams = (
|
|
34
|
-
finder: string,
|
|
35
|
-
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>
|
|
36
|
-
): QueryParams => {
|
|
37
|
-
return {
|
|
38
|
-
finder,
|
|
39
|
-
finderParams: JSON.stringify(finderParams),
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const createAItemAPI = <
|
|
44
|
-
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
45
|
-
S extends string,
|
|
46
|
-
L1 extends string = never,
|
|
47
|
-
L2 extends string = never,
|
|
48
|
-
L3 extends string = never,
|
|
49
|
-
L4 extends string = never,
|
|
50
|
-
L5 extends string = never
|
|
51
|
-
>(
|
|
52
|
-
api: HttpApi,
|
|
53
|
-
pkType: S,
|
|
54
|
-
pathNames: PathNamesArray<L1, L2, L3, L4, L5>,
|
|
55
|
-
options?: ClientApiOptions,
|
|
56
|
-
): ClientApi<V, S, L1, L2, L3, L4, L5> => {
|
|
57
|
-
|
|
58
|
-
logger.default('createAItemAPI', { pkType, pathNames, options });
|
|
59
|
-
|
|
60
|
-
let mergedOptions: ClientApiOptions;
|
|
61
|
-
|
|
62
|
-
const defaultOptions: ClientApiOptions = {
|
|
63
|
-
readAuthenticated: true,
|
|
64
|
-
allAuthenticated: true,
|
|
65
|
-
writeAuthenticated: true,
|
|
66
|
-
getOptions: {},
|
|
67
|
-
postOptions: {},
|
|
68
|
-
putOptions: {},
|
|
69
|
-
deleteOptions: {},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
if (options) {
|
|
73
|
-
mergedOptions = Object.assign({}, defaultOptions, options);
|
|
74
|
-
} else {
|
|
75
|
-
mergedOptions = defaultOptions;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const utilities = createUtilities<V, S, L1, L2, L3, L4, L5>(pkType, pathNames);
|
|
79
|
-
const operations = getOperations<V, S, L1, L2, L3, L4, L5>(api, mergedOptions, utilities);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
action: operations.action,
|
|
83
|
-
all: operations.all,
|
|
84
|
-
allAction: operations.allAction,
|
|
85
|
-
allFacet: operations.allFacet,
|
|
86
|
-
create: operations.create,
|
|
87
|
-
facet: operations.facet,
|
|
88
|
-
find: operations.find,
|
|
89
|
-
findOne: operations.findOne,
|
|
90
|
-
get: operations.get,
|
|
91
|
-
one: operations.one,
|
|
92
|
-
remove: operations.remove,
|
|
93
|
-
update: operations.update,
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/CItemAPI.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
ComKey,
|
|
4
|
-
Item,
|
|
5
|
-
ItemQuery,
|
|
6
|
-
LocKeyArray,
|
|
7
|
-
PriKey,
|
|
8
|
-
} from "@fjell/core";
|
|
9
|
-
import {
|
|
10
|
-
HttpApi
|
|
11
|
-
} from "@fjell/http-api";
|
|
12
|
-
import { createAItemAPI, PathNamesArray } from "./AItemAPI";
|
|
13
|
-
|
|
14
|
-
import LibLogger from "@/logger";
|
|
15
|
-
import { ClientApi } from "./ClientApi";
|
|
16
|
-
import { ClientApiOptions } from "./ClientApiOptions";
|
|
17
|
-
|
|
18
|
-
const logger = LibLogger.get('CItemAPI');
|
|
19
|
-
|
|
20
|
-
export interface CItemApi<
|
|
21
|
-
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
22
|
-
S extends string,
|
|
23
|
-
L1 extends string,
|
|
24
|
-
L2 extends string = never,
|
|
25
|
-
L3 extends string = never,
|
|
26
|
-
L4 extends string = never,
|
|
27
|
-
L5 extends string = never
|
|
28
|
-
> extends ClientApi<V, S, L1, L2, L3, L4, L5> {
|
|
29
|
-
action: (
|
|
30
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
31
|
-
action: string,
|
|
32
|
-
body: any,
|
|
33
|
-
) => Promise<V>;
|
|
34
|
-
all: (
|
|
35
|
-
query: ItemQuery,
|
|
36
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
37
|
-
) => Promise<V[]>;
|
|
38
|
-
allAction: (
|
|
39
|
-
action: string,
|
|
40
|
-
body?: any,
|
|
41
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
42
|
-
) => Promise<V[]>;
|
|
43
|
-
allFacet: (
|
|
44
|
-
facet: string,
|
|
45
|
-
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
46
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
47
|
-
) => Promise<any>;
|
|
48
|
-
get: (
|
|
49
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
50
|
-
) => Promise<V | null>;
|
|
51
|
-
create: (
|
|
52
|
-
item: Partial<Item<S, L1, L2, L3, L4, L5>>,
|
|
53
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
54
|
-
) => Promise<V>;
|
|
55
|
-
remove: (
|
|
56
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
57
|
-
) => Promise<boolean>;
|
|
58
|
-
update: (
|
|
59
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
60
|
-
item: Partial<Item<S, L1, L2, L3, L4, L5>>,
|
|
61
|
-
) => Promise<V>;
|
|
62
|
-
facet: (
|
|
63
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
64
|
-
facet: string,
|
|
65
|
-
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
66
|
-
) => Promise<any>;
|
|
67
|
-
find: (
|
|
68
|
-
finder: string,
|
|
69
|
-
finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
70
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
71
|
-
) => Promise<V[]>;
|
|
72
|
-
findOne: (
|
|
73
|
-
finder: string,
|
|
74
|
-
finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
75
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
76
|
-
) => Promise<V>;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const createCItemApi = <
|
|
80
|
-
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
81
|
-
S extends string,
|
|
82
|
-
L1 extends string,
|
|
83
|
-
L2 extends string = never,
|
|
84
|
-
L3 extends string = never,
|
|
85
|
-
L4 extends string = never,
|
|
86
|
-
L5 extends string = never
|
|
87
|
-
>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions): CItemApi<V, S, L1, L2, L3, L4, L5> => {
|
|
88
|
-
|
|
89
|
-
logger.default('createCItemApi', { api, type, pathNames, options });
|
|
90
|
-
|
|
91
|
-
const aItemAPI = createAItemAPI(api, type, pathNames, options);
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
action: aItemAPI.action,
|
|
95
|
-
all: aItemAPI.all,
|
|
96
|
-
allAction: aItemAPI.allAction,
|
|
97
|
-
allFacet: aItemAPI.allFacet,
|
|
98
|
-
one: aItemAPI.one,
|
|
99
|
-
get: aItemAPI.get,
|
|
100
|
-
create: aItemAPI.create,
|
|
101
|
-
remove: aItemAPI.remove,
|
|
102
|
-
update: aItemAPI.update,
|
|
103
|
-
facet: aItemAPI.facet,
|
|
104
|
-
find: aItemAPI.find,
|
|
105
|
-
findOne: aItemAPI.findOne,
|
|
106
|
-
} as unknown as CItemApi<V, S, L1, L2, L3, L4, L5>;
|
|
107
|
-
}
|
package/src/ClientApi.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ComKey, Item, ItemQuery, LocKeyArray, PriKey } from "@fjell/core";
|
|
2
|
-
|
|
3
|
-
export interface ClientApi<
|
|
4
|
-
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
5
|
-
S extends string,
|
|
6
|
-
L1 extends string = never,
|
|
7
|
-
L2 extends string = never,
|
|
8
|
-
L3 extends string = never,
|
|
9
|
-
L4 extends string = never,
|
|
10
|
-
L5 extends string = never
|
|
11
|
-
> {
|
|
12
|
-
action: (
|
|
13
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
14
|
-
action: string,
|
|
15
|
-
body?: any,
|
|
16
|
-
) => Promise<V>;
|
|
17
|
-
all: (
|
|
18
|
-
query: ItemQuery,
|
|
19
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
20
|
-
) => Promise<V[]>;
|
|
21
|
-
allAction: (
|
|
22
|
-
action: string,
|
|
23
|
-
body?: any,
|
|
24
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
25
|
-
) => Promise<V[]>;
|
|
26
|
-
allFacet: (
|
|
27
|
-
facet: string,
|
|
28
|
-
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
29
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
30
|
-
) => Promise<any>;
|
|
31
|
-
create: (
|
|
32
|
-
item: Partial<Item<S, L1, L2, L3, L4, L5>>,
|
|
33
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
34
|
-
) => Promise<V>;
|
|
35
|
-
facet: (
|
|
36
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
37
|
-
facet: string,
|
|
38
|
-
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
39
|
-
) => Promise<any>;
|
|
40
|
-
find: (
|
|
41
|
-
finder: string,
|
|
42
|
-
finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
43
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
44
|
-
) => Promise<V[]>;
|
|
45
|
-
findOne: (
|
|
46
|
-
finder: string,
|
|
47
|
-
finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
48
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
49
|
-
) => Promise<V>;
|
|
50
|
-
get: (
|
|
51
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
52
|
-
) => Promise<V | null>;
|
|
53
|
-
one: (
|
|
54
|
-
query: ItemQuery,
|
|
55
|
-
locations?: LocKeyArray<L1, L2, L3, L4, L5> | []
|
|
56
|
-
) => Promise<V | null>;
|
|
57
|
-
remove: (
|
|
58
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
59
|
-
) => Promise<boolean>;
|
|
60
|
-
update: (
|
|
61
|
-
ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,
|
|
62
|
-
item: Partial<Item<S, L1, L2, L3, L4, L5>>,
|
|
63
|
-
) => Promise<V>;
|
|
64
|
-
}
|
package/src/ClientApiOptions.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Item } from "@fjell/core";
|
|
2
|
-
import { ClientApi } from "./ClientApi";
|
|
3
|
-
import { DeleteMethodOptions, GetMethodOptions, PostMethodOptions, PutMethodOptions } from "@fjell/http-api";
|
|
4
|
-
|
|
5
|
-
export interface ClientApiOptions {
|
|
6
|
-
readAuthenticated?: boolean;
|
|
7
|
-
allAuthenticated?: boolean;
|
|
8
|
-
writeAuthenticated?: boolean;
|
|
9
|
-
parentApi?: ClientApi<
|
|
10
|
-
Item<string, string | never, string | never, string | never, string | never, string | never>,
|
|
11
|
-
string,
|
|
12
|
-
string | never,
|
|
13
|
-
string | never,
|
|
14
|
-
string | never,
|
|
15
|
-
string | never,
|
|
16
|
-
string | never
|
|
17
|
-
>;
|
|
18
|
-
getOptions?: Partial<GetMethodOptions>;
|
|
19
|
-
postOptions?: Partial<PostMethodOptions>;
|
|
20
|
-
putOptions?: Partial<PutMethodOptions>;
|
|
21
|
-
deleteOptions?: Partial<DeleteMethodOptions>;
|
|
22
|
-
}
|
package/src/PItemAPI.ts
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { ComKey, Item, ItemQuery, PriKey } from "@fjell/core";
|
|
2
|
-
import { HttpApi } from "@fjell/http-api";
|
|
3
|
-
import { createAItemAPI } from "./AItemAPI";
|
|
4
|
-
import { ClientApi } from "./ClientApi";
|
|
5
|
-
|
|
6
|
-
import LibLogger from "@/logger";
|
|
7
|
-
import { ClientApiOptions } from "./ClientApiOptions";
|
|
8
|
-
const logger = LibLogger.get('PItemAPI');
|
|
9
|
-
|
|
10
|
-
export interface PItemApi<
|
|
11
|
-
V extends Item<S>,
|
|
12
|
-
S extends string
|
|
13
|
-
> extends ClientApi<V, S> {
|
|
14
|
-
|
|
15
|
-
action: (
|
|
16
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
17
|
-
action: string,
|
|
18
|
-
body: any,
|
|
19
|
-
) => Promise<V>;
|
|
20
|
-
|
|
21
|
-
all: (
|
|
22
|
-
query: ItemQuery,
|
|
23
|
-
) => Promise<V[]>;
|
|
24
|
-
|
|
25
|
-
allAction: (
|
|
26
|
-
action: string,
|
|
27
|
-
body?: any,
|
|
28
|
-
) => Promise<V[]>;
|
|
29
|
-
|
|
30
|
-
allFacet: (
|
|
31
|
-
facet: string,
|
|
32
|
-
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
33
|
-
) => Promise<any>;
|
|
34
|
-
|
|
35
|
-
one: (
|
|
36
|
-
query: ItemQuery,
|
|
37
|
-
) => Promise<V | null>;
|
|
38
|
-
|
|
39
|
-
get: (
|
|
40
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
41
|
-
) => Promise<V | null>;
|
|
42
|
-
|
|
43
|
-
create: (
|
|
44
|
-
item: Partial<Item<S>>,
|
|
45
|
-
) => Promise<V>;
|
|
46
|
-
|
|
47
|
-
remove: (
|
|
48
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
49
|
-
) => Promise<boolean>;
|
|
50
|
-
|
|
51
|
-
update: (
|
|
52
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
53
|
-
item: Partial<Item<S>>,
|
|
54
|
-
) => Promise<V>;
|
|
55
|
-
|
|
56
|
-
facet: (
|
|
57
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
58
|
-
facet: string,
|
|
59
|
-
params?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
60
|
-
) => Promise<any>;
|
|
61
|
-
|
|
62
|
-
find: (
|
|
63
|
-
finder: string,
|
|
64
|
-
finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
65
|
-
) => Promise<V[]>;
|
|
66
|
-
|
|
67
|
-
findOne: (
|
|
68
|
-
finder: string,
|
|
69
|
-
finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,
|
|
70
|
-
) => Promise<V>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const createPItemApi = <V extends Item<S>, S extends string>(
|
|
74
|
-
api: HttpApi,
|
|
75
|
-
type: S,
|
|
76
|
-
pathName: string,
|
|
77
|
-
options?: ClientApiOptions
|
|
78
|
-
): PItemApi<V, S> => {
|
|
79
|
-
|
|
80
|
-
logger.default('createPItemApi', { type, pathName, options });
|
|
81
|
-
|
|
82
|
-
const aItemAPI = createAItemAPI<V, S>(api, type, [pathName], options);
|
|
83
|
-
|
|
84
|
-
const action =
|
|
85
|
-
async (
|
|
86
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
87
|
-
action: string,
|
|
88
|
-
body: any = {},
|
|
89
|
-
): Promise<V> =>
|
|
90
|
-
await aItemAPI.action(ik, action, body) as V;
|
|
91
|
-
|
|
92
|
-
const all =
|
|
93
|
-
async (
|
|
94
|
-
query: ItemQuery = {} as ItemQuery,
|
|
95
|
-
): Promise<V[]> =>
|
|
96
|
-
await aItemAPI.all(query, []) as V[];
|
|
97
|
-
|
|
98
|
-
const allAction =
|
|
99
|
-
async (
|
|
100
|
-
action: string,
|
|
101
|
-
body: any = {},
|
|
102
|
-
): Promise<V[]> =>
|
|
103
|
-
await aItemAPI.allAction(action, body, []) as V[];
|
|
104
|
-
|
|
105
|
-
const allFacet =
|
|
106
|
-
async (
|
|
107
|
-
facet: string,
|
|
108
|
-
params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
109
|
-
): Promise<any> =>
|
|
110
|
-
await aItemAPI.allFacet(facet, params) as any;
|
|
111
|
-
|
|
112
|
-
const one =
|
|
113
|
-
async (
|
|
114
|
-
query: ItemQuery = {} as ItemQuery,
|
|
115
|
-
): Promise<V | null> =>
|
|
116
|
-
await aItemAPI.one(query, []) as V | null;
|
|
117
|
-
|
|
118
|
-
const get =
|
|
119
|
-
async (
|
|
120
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
121
|
-
): Promise<V | null> =>
|
|
122
|
-
await aItemAPI.get(ik) as V | null;
|
|
123
|
-
|
|
124
|
-
const create =
|
|
125
|
-
async (
|
|
126
|
-
item: Partial<Item<S>>,
|
|
127
|
-
): Promise<V> =>
|
|
128
|
-
await aItemAPI.create(item, []) as V;
|
|
129
|
-
|
|
130
|
-
const remove =
|
|
131
|
-
async (
|
|
132
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
133
|
-
): Promise<boolean> =>
|
|
134
|
-
await aItemAPI.remove(ik) as boolean;
|
|
135
|
-
|
|
136
|
-
const update =
|
|
137
|
-
async (
|
|
138
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
139
|
-
item: Partial<Item<S>>,
|
|
140
|
-
): Promise<V> =>
|
|
141
|
-
await aItemAPI.update(ik, item) as V;
|
|
142
|
-
|
|
143
|
-
const facet =
|
|
144
|
-
async (
|
|
145
|
-
ik: PriKey<S> | ComKey<S, never, never, never, never, never>,
|
|
146
|
-
facet: string,
|
|
147
|
-
params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
148
|
-
): Promise<any> =>
|
|
149
|
-
await aItemAPI.facet(ik, facet, params) as any;
|
|
150
|
-
|
|
151
|
-
const find =
|
|
152
|
-
async (
|
|
153
|
-
finder: string,
|
|
154
|
-
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
155
|
-
): Promise<V[]> =>
|
|
156
|
-
await aItemAPI.find(finder, finderParams) as V[];
|
|
157
|
-
|
|
158
|
-
const findOne =
|
|
159
|
-
async (
|
|
160
|
-
finder: string,
|
|
161
|
-
finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},
|
|
162
|
-
): Promise<V> =>
|
|
163
|
-
await aItemAPI.findOne(finder, finderParams) as V;
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
...aItemAPI,
|
|
167
|
-
action,
|
|
168
|
-
all,
|
|
169
|
-
allAction,
|
|
170
|
-
allFacet,
|
|
171
|
-
one,
|
|
172
|
-
get,
|
|
173
|
-
create,
|
|
174
|
-
remove,
|
|
175
|
-
update,
|
|
176
|
-
facet,
|
|
177
|
-
find,
|
|
178
|
-
findOne,
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
};
|