Skip to content

Commit 9f249de

Browse files
Adjust operation actions name (#1)
* Add CI and publish workflows * Add package-lock.json to lock npm dependencies * Added test-project example * Regenerate package-lock.json * update lint rules and regenerate package-lock.json * lint * add @eslint/js and globals * use npm ci and run @dataform/cli in test script * correct @dataform/cli dependency in package.json * add dependabot config to enable weekly npm and github-actions updates * deps update * Use database.schema.name for proto target fallback in getActionName and update tests * Update test-project/README.md Co-authored-by: Copilot <[email protected]> * Bump package version to 0.1.0, update README and CHANGELOG, refresh test-project lockfile * Clarify breaking change in CHANGELOG for getActionName schema requirement --------- Co-authored-by: Copilot <[email protected]>
1 parent 6d37417 commit 9f249de

26 files changed

+11429
-255
lines changed

.eslintrc.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directories:
5+
- "/"
6+
- "test-project/"
7+
schedule:
8+
interval: "weekly"
9+
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"

.github/linters/eslint.config.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
4+
export default [
5+
{
6+
ignores: ['node_modules/**']
7+
},
8+
js.configs.recommended,
9+
{
10+
languageOptions: {
11+
ecmaVersion: 2022,
12+
sourceType: 'module',
13+
globals: {
14+
...globals.node,
15+
...globals.jest,
16+
17+
// Dataform-specific globals
18+
publish: 'readonly',
19+
constant: 'readonly',
20+
ctx: 'readonly',
21+
}
22+
},
23+
rules: {
24+
// Basic formatting rules
25+
'indent': ['error', 2],
26+
'quotes': ['error', 'single'],
27+
'semi': ['error', 'never']
28+
}
29+
}
30+
]

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
lint-and-test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run linter
26+
run: npm run lint
27+
28+
- name: Run tests
29+
run: npm test

.github/workflows/publish.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
registry-url: 'https://registry.npmjs.org'
26+
cache: 'npm'
27+
28+
- name: Update npm
29+
run: npm install -g npm@latest
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Run linter
35+
run: npm run lint
36+
37+
- name: Run tests
38+
run: npm test
39+
40+
- name: Publish to npm
41+
run: npm publish

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919

2020
### Security
2121

22+
## [0.1.0] - 2025-10-27
23+
24+
### Changed
25+
26+
- **Breaking Change**: Updated `getActionName` to use `database.schema.name` format for operation actions. Action names in your reservation configuration must now include the schema. For example, change `'my-project.my_table'` to `'my-project.my_schema.my_table'` to match Dataform's actual behavior.
27+
2228
## [0.0.1] - 2025-10-06
2329

2430
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Add the dependency to your `package.json`:
2222
```json
2323
{
2424
"dependencies": {
25-
"@masthead-data/dataform-package": "0.0.1"
25+
"@masthead-data/dataform-package": "0.1.0"
2626
}
2727
}
2828
```

examples.js

Lines changed: 0 additions & 125 deletions
This file was deleted.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function getActionName(ctx) {
1515
// Fallback: construct from proto target
1616
if (ctx?.operation?.proto?.target) {
1717
const target = ctx.operation.proto.target
18-
return target ? `${target.database}.${target.name}` : null
18+
return target ? `${target.database}.${target.schema}.${target.name}` : null
1919
}
2020

2121
return null

jest.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
module.exports = {
22
testEnvironment: 'node',
33
collectCoverage: true,
4-
collectCoverageFrom: [
5-
'index.js'
6-
],
74
coverageDirectory: 'coverage',
8-
coverageReporters: ['text', 'lcov', 'html'],
5+
coverageReporters: ['text'],
96
testMatch: [
107
'**/test/**/*.test.js'
118
]

0 commit comments

Comments
 (0)