@cobol-ts/template 0.0.0-stage → 0.0.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.
package/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c)2020-2023 Philip Rice
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @cobol-ts/template
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Purpose
4
+
5
+ This module expands variables in text using a configurable delimiter syntax and an object dictionary. It supports alternative variable definitions and value-transforming functions, rather than compiling or executing arbitrary TypeScript templates.
6
+
7
+ ## Public API
8
+
9
+ `dereference(context, dictionary, text, options)` expands references. Import `dollarsBracesVarDefn`, `mustachesVariableDefn`, `colonPrefixedVarDefn`, `fulltextVariableDefn` or `doubleXmlVariableDefn` from this package to choose a reference syntax. The `variableDefn` option is important: without one, the implementation returns the input text unchanged. `replaceVar` and `processVariable` expose lower-level replacement handling, and `stringFunctions` offers functions for transforming extracted values.
10
+
11
+ ## Example
12
+
13
+ ```ts
14
+ import {dereference, dollarsBracesVarDefn} from '@cobol-ts/template';
15
+ const result = dereference('example', {customer: {name: 'Ada'}},
16
+ 'Hello ${customer.name}', {variableDefn: dollarsBracesVarDefn});
17
+ ```
18
+
19
+ ## Behaviour and responsibilities
20
+
21
+ The options include undefined-value handling, error-throwing behaviour and custom template functions. The lookup routines in [`src/dot.language.ts`](src/dot.language.ts) traverse dictionary paths, while [`src/variables.ts`](src/variables.ts) handles substitution and error context. Function syntax and supported built-ins live in [`src/stringFunctions.ts`](src/stringFunctions.ts). This is string substitution, not an escaping or security boundary: apply context-appropriate escaping before inserting output into HTML, shell commands or SQL.
@@ -0,0 +1,3 @@
1
+ export * from './src/variables';
2
+ export * from './src/stringFunctions';
3
+ export * from "./src/variableDefn";
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ //Copyright (c)2020-2023 Philip Rice. <br />Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the Software), to dealin the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: <br />The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED AS
18
+ __exportStar(require("./src/variables"), exports);
19
+ __exportStar(require("./src/stringFunctions"), exports);
20
+ __exportStar(require("./src/variableDefn"), exports);
21
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@cobol-ts/template",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "A small template language",
4
+ "version": "0.0.1",
5
+ "main": "dist/index",
6
+ "types": "dist/index",
7
+ "browserslist": {
8
+ "development": [
9
+ "last 1 chrome version",
10
+ "last 1 firefox version",
11
+ "last 1 safari version"
12
+ ],
13
+ "production": [
14
+ ">0.2%",
15
+ "not dead",
16
+ "not op_mini all"
17
+ ]
18
+ },
19
+ "dependencies": {
20
+ "@cobol-ts/errors": "0.0.1",
21
+ "@cobol-ts/records": "0.0.1",
22
+ "@cobol-ts/safe": "0.0.1"
23
+ },
24
+ "devDependencies": {
25
+ "@testing-library/jest-dom": "^6.1.4",
26
+ "@types/jest": "^29.0.0",
27
+ "@types/node": "^14.0.0",
28
+ "jest": "^29.0.0",
29
+ "ts-jest": "^29.0.0",
30
+ "typescript": "^5.2.2"
31
+ },
32
+ "eslintConfig": {
33
+ "extends": [
34
+ "react-app",
35
+ "react-app/jest"
36
+ ],
37
+ "overrides": [
38
+ {
39
+ "files": [
40
+ "**/*.stories.*"
41
+ ],
42
+ "rules": {
43
+ "import/no-anonymous-default-export": "off"
44
+ }
45
+ }
46
+ ]
47
+ },
48
+ "files": [
49
+ "dist/index.js",
50
+ "dist/index.d.ts",
51
+ "dist/src/"
52
+ ],
53
+ "keywords": [
54
+ "indexing"
55
+ ],
56
+ "license": "MIT",
57
+ "repository": "git@github.com:intellimaintain/intellimaintain.git",
58
+ "scripts": {
59
+ "test": "jest --config jest.config.json --env node",
60
+ "test:watch": "npm run test -- --watch"
61
+ }
6
62
  }