Skip to content

Commit

Permalink
Ci/add provenance (#26)
Browse files Browse the repository at this point in the history
* chore: bump libs

* ci: bump actions

* ci: add provenance

* chore: eslint fix

* chore: version bump
  • Loading branch information
jkoenig134 authored Nov 17, 2023
1 parent e4d27bd commit 8ddb4d2
Show file tree
Hide file tree
Showing 8 changed files with 881 additions and 383 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: javascript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: javascript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
7 changes: 5 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ on:
jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: browser-actions/setup-chrome@latest
Expand Down
1,195 changes: 845 additions & 350 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js-soft/ts-serval",
"version": "2.0.9",
"version": "2.0.10",
"description": "TypeScript Runtime Serialization and Validation",
"homepage": "https://github.com/js-soft/ts-serval#readme",
"repository": "github:js-soft/ts-serval",
Expand Down Expand Up @@ -44,28 +44,29 @@
"reflect-metadata": "^0.1.13"
},
"devDependencies": {
"@js-soft/eslint-config-ts": "1.6.3",
"@js-soft/license-check": "1.0.6",
"@types/chai": "^4.3.5",
"@types/lodash": "^4.14.195",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.4",
"@js-soft/eslint-config-ts": "1.6.5",
"@js-soft/license-check": "1.0.8",
"@types/chai": "^4.3.10",
"@types/lodash": "^4.14.201",
"@types/mocha": "^10.0.4",
"@types/node": "^20.9.1",
"bt-runner": "^4.0.2",
"buffer": "^6.0.3",
"chai": "^4.3.7",
"eslint": "8.45.0",
"chai": "^4.3.10",
"eslint": "8.53.0",
"madge": "^6.1.0",
"mocha": "^10.2.0",
"mocha-param": "^2.0.1",
"prettier": "^2.8.4",
"prettier": "^3.1.0",
"terser-webpack-plugin": "5.3.9",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.6",
"webpack": "^5.88.2",
"typescript": "^5.2.2",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
}
}
4 changes: 2 additions & 2 deletions src/SerializableBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export class SerializableBase {
verbose = true
}
if (value instanceof SerializableBase) {
if (descriptor.enforceString || serializeAsString) {
if (!!descriptor.enforceString || serializeAsString) {
return value.serialize(verbose)
}
return value.toJSON(verbose)
Expand All @@ -275,7 +275,7 @@ export class SerializableBase {
"Object is not yet resolved. You have to wait for Promises to proceed with serialization."
)
} else if (typeof value.toJSON === "function") {
if (descriptor.enforceString || serializeAsString) {
if (!!descriptor.enforceString || serializeAsString) {
return JSON.stringify(value.toJSON())
}
return value.toJSON()
Expand Down
15 changes: 7 additions & 8 deletions src/parsing/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export abstract class Parser {
let fct: Function | undefined
const args: any[] = [value]

if ((descriptor.parseUnknown || descriptor.type === "Serializable") && value && value["@type"]) {
if ((!!descriptor.parseUnknown || descriptor.type === "Serializable") && value?.["@type"]) {
return caller.deserializeUnknown(value)
}

Expand Down Expand Up @@ -184,11 +184,10 @@ export abstract class Parser {
const args: any[] = [value]

if (
(descriptor.parseUnknown ||
(!!descriptor.parseUnknown ||
descriptor.type === "Serializable" ||
descriptor.type === "SerializableAsync") &&
value &&
value["@type"]
value?.["@type"]
) {
// eslint-disable-next-line @typescript-eslint/return-await
return await caller.deserializeUnknown(value)
Expand Down Expand Up @@ -357,7 +356,7 @@ export abstract class Parser {
return value
} else if (descriptor.unionTypes?.some((t) => value instanceof t)) {
return value
} else if ((typeof value === "string" && descriptor.deserializeStrings) || descriptor.enforceString) {
} else if (!!(typeof value === "string" && descriptor.deserializeStrings) || descriptor.enforceString) {
return Parser.parseStringObject(value, descriptor, className, caller)
} else if (descriptor.any) {
return value
Expand All @@ -367,7 +366,7 @@ export abstract class Parser {

if (
value?.["@type"] &&
(descriptor.parseUnknown ||
(!!descriptor.parseUnknown ||
descriptor.type === "Serializable" ||
typeof descriptor.allowSubclasses === "undefined" ||
descriptor.allowSubclasses)
Expand Down Expand Up @@ -440,7 +439,7 @@ export abstract class Parser {
return await Promise.resolve(value)
} else if (descriptor.unionTypes?.some((t) => value instanceof t)) {
return await Promise.resolve(value)
} else if ((typeof value === "string" && descriptor.deserializeStrings) || descriptor.enforceString) {
} else if (!!(typeof value === "string" && descriptor.deserializeStrings) || descriptor.enforceString) {
return await Parser.parseStringObjectAsync(value, descriptor, className, caller)
} else if (descriptor.any) {
return await Promise.resolve(value)
Expand All @@ -450,7 +449,7 @@ export abstract class Parser {

if (
value?.["@type"] &&
(descriptor.parseUnknown ||
(!!descriptor.parseUnknown ||
descriptor.type === "Serializable" ||
typeof descriptor.allowSubclasses === "undefined" ||
descriptor.allowSubclasses)
Expand Down

0 comments on commit 8ddb4d2

Please sign in to comment.