-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat((pin 262) crr dd): [sc-24352] Improve Human Readable ID (#658)
* feat: refactor tests and introduce year getter [sc-24352] * chore: remove logs * test: fix expects * fix: correctly pull query from SM config [sc-24352] * chore: remove log [sc-24352] * refactor: tidying and revert today [sc-24352]
- Loading branch information
1 parent
004a97e
commit fe8c646
Showing
7 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
|
||
module.exports = class Timestamp { | ||
init (resourceConfig, env) { | ||
this.query = resourceConfig.query | ||
this.timestamp = env.bootedServices.timestamp | ||
} | ||
|
||
run (event, context) { | ||
context.sendTaskSuccess(this.timestamp.now()) | ||
if (this.query === '$TODAY') { | ||
return context.sendTaskSuccess(this.timestamp.today()) | ||
} | ||
|
||
if (this.query === '$YEAR') { | ||
return context.sendTaskSuccess(this.timestamp.getYear()) | ||
} | ||
|
||
return context.sendTaskSuccess(this.timestamp.now()) | ||
} // run | ||
} // GetRegistryKey | ||
} |
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
test/fixtures/blueprints/timestamp-blueprint/state-machines/timestamp-today.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"Comment": "Blueprint to get timestamp", | ||
"version": "1.0", | ||
"StartAt": "Timestamp", | ||
"States": { | ||
"Timestamp": { | ||
"Type": "Task", | ||
"Resource": "module:timestamp", | ||
"ResourceConfig": { | ||
"query": "$TODAY" | ||
}, | ||
"ResultPath": "$.timestamp", | ||
"End": true | ||
} | ||
}, | ||
"restrictions": [ | ||
{ | ||
"roleId": "$authenticated", | ||
"allows": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
test/fixtures/blueprints/timestamp-blueprint/state-machines/timestamp-year.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"Comment": "Blueprint to get timestamp", | ||
"version": "1.0", | ||
"StartAt": "Timestamp", | ||
"States": { | ||
"Timestamp": { | ||
"Type": "Task", | ||
"Resource": "module:timestamp", | ||
"ResourceConfig": { | ||
"query": "$YEAR" | ||
}, | ||
"ResultPath": "$.timestamp", | ||
"End": true | ||
} | ||
}, | ||
"restrictions": [ | ||
{ | ||
"roleId": "$authenticated", | ||
"allows": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters