@shwfed/nuxt 0.1.5
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/module.d.mts +9 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +16 -0
- package/dist/runtime/plugins/cel.d.ts +2 -0
- package/dist/runtime/plugins/cel.js +36 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/types.d.mts +3 -0
- package/package.json +80 -0
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@shwfed/nuxt",
|
|
6
|
+
configKey: "shwfed"
|
|
7
|
+
},
|
|
8
|
+
// Default configuration options of the Nuxt module
|
|
9
|
+
defaults: {},
|
|
10
|
+
setup(_options, _nuxt) {
|
|
11
|
+
const resolver = createResolver(import.meta.url);
|
|
12
|
+
addPlugin(resolver.resolve("./runtime/plugins/cel"));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TypeError, EvaluationError } from "@marcbachmann/cel-js";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { Effect, Either } from "effect";
|
|
4
|
+
import { createEnvironment } from "~/utils/cel";
|
|
5
|
+
export default defineNuxtPlugin(() => {
|
|
6
|
+
const env = createEnvironment();
|
|
7
|
+
return {
|
|
8
|
+
provide: {
|
|
9
|
+
dsl: {
|
|
10
|
+
check: (source) => {
|
|
11
|
+
const result = env.check(source);
|
|
12
|
+
if (result.valid) {
|
|
13
|
+
return Either.right(result.type);
|
|
14
|
+
} else {
|
|
15
|
+
return Either.left(result.error);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
evaluate: (source, context) => Effect.gen(function* () {
|
|
19
|
+
return yield* Effect.tryPromise({
|
|
20
|
+
try: async () => env.evaluate(source, defu(context, {
|
|
21
|
+
now: /* @__PURE__ */ new Date()
|
|
22
|
+
})),
|
|
23
|
+
catch: (error) => {
|
|
24
|
+
if (error instanceof TypeError) {
|
|
25
|
+
return error;
|
|
26
|
+
} else if (error instanceof EvaluationError) {
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
});
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shwfed/nuxt",
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/types.d.mts",
|
|
13
|
+
"import": "./dist/module.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/module.mjs",
|
|
17
|
+
"typesVersions": {
|
|
18
|
+
"*": {
|
|
19
|
+
".": [
|
|
20
|
+
"./dist/types.d.mts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"workspaces": [
|
|
28
|
+
"playground"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"prepack": "nuxt-module-build build",
|
|
32
|
+
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
33
|
+
"dev:build": "nuxt build playground",
|
|
34
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
35
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"postinstall": "nuxt prepare && husky",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest watch",
|
|
40
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@date-fns/tz": "^1.4.1",
|
|
44
|
+
"@marcbachmann/cel-js": "^7.2.1",
|
|
45
|
+
"@nuxt/kit": "^4.3.0",
|
|
46
|
+
"date-fns": "^4.1.0",
|
|
47
|
+
"defu": "^6.1.4",
|
|
48
|
+
"effect": "^3.19.15"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@commitlint/cli": "^20.3.1",
|
|
52
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
53
|
+
"@nuxt/devtools": "^3.1.1",
|
|
54
|
+
"@nuxt/eslint": "1.13.0",
|
|
55
|
+
"@nuxt/eslint-config": "^1.13.0",
|
|
56
|
+
"@nuxt/icon": "2.2.1",
|
|
57
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
58
|
+
"@nuxt/schema": "^4.3.0",
|
|
59
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
60
|
+
"@types/node": "latest",
|
|
61
|
+
"changelogen": "^0.6.2",
|
|
62
|
+
"eslint": "^9.39.2",
|
|
63
|
+
"husky": "^9.1.7",
|
|
64
|
+
"lint-staged": "^16.2.7",
|
|
65
|
+
"nuxt": "^4.3.0",
|
|
66
|
+
"typescript": "~5.9.3",
|
|
67
|
+
"vitest": "^4.0.18",
|
|
68
|
+
"vue-tsc": "^3.2.4"
|
|
69
|
+
},
|
|
70
|
+
"commitlint": {
|
|
71
|
+
"extends": [
|
|
72
|
+
"@commitlint/config-conventional"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"lint-staged": {
|
|
76
|
+
"*.{js,jsx,ts,tsx,vue}": [
|
|
77
|
+
"eslint --fix"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|