@sprucelabs/heartwood-polish 6.3.480 → 7.0.0

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.
Files changed (35) hide show
  1. package/build/.spruce/errors/errors.types.d.ts +13 -13
  2. package/build/.spruce/errors/errors.types.js +0 -2
  3. package/build/.spruce/errors/heartwoodPolish/assertionFailed.schema.js +1 -1
  4. package/build/.spruce/errors/heartwoodPolish/fileNotFound.schema.js +3 -3
  5. package/build/.spruce/errors/heartwoodPolish/invalidActionName.schema.js +5 -5
  6. package/build/.spruce/errors/heartwoodPolish/invalidAssertName.schema.js +3 -3
  7. package/build/.spruce/errors/heartwoodPolish/invalidStep.schema.js +1 -1
  8. package/build/.spruce/errors/heartwoodPolish/invalidTarget.schema.js +3 -3
  9. package/build/.spruce/errors/heartwoodPolish/missingAssertion.schema.js +1 -1
  10. package/build/.spruce/errors/heartwoodPolish/namespaceNotFound.schema.js +3 -3
  11. package/build/.spruce/errors/heartwoodPolish/tooManyPolishFiles.schema.js +1 -1
  12. package/build/.spruce/errors/options.types.d.ts +1 -1
  13. package/build/.spruce/schemas/fields/fields.types.d.ts +1 -1
  14. package/build/errors/SpruceError.js +1 -1
  15. package/build/importing/StepGenerator.js +1 -0
  16. package/build/loading/StepLoader.js +16 -12
  17. package/build/performingActions/AbstractAction.js +3 -0
  18. package/build/performingActions/ActionFactory.js +3 -1
  19. package/build/performingActions/AssertAction.js +16 -17
  20. package/build/performingActions/ClearTextAction.js +1 -0
  21. package/build/performingActions/ClickAction.js +1 -0
  22. package/build/performingActions/ConfigureAction.js +1 -0
  23. package/build/performingActions/DragAndDropAction.js +3 -1
  24. package/build/performingActions/FileAction.js +4 -1
  25. package/build/performingActions/RedirectAction.js +3 -1
  26. package/build/performingActions/SelectAction.js +2 -0
  27. package/build/performingActions/TypeTextAction.js +4 -2
  28. package/build/performingActions/WaitAction.js +1 -0
  29. package/build/performingActions/assertions/assertDoesNotInclude.js +1 -2
  30. package/build/performingActions/assertions/assertPresentSlide.js +1 -1
  31. package/build/polish.js +9 -8
  32. package/build/polishing/Polisher.js +8 -3
  33. package/build/targeting/TargetSelectorGenerator.js +44 -48
  34. package/package.json +17 -17
  35. package/tsconfig.json +3 -4
@@ -14,7 +14,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
14
14
  export declare namespace SpruceErrors.HeartwoodPolish {
15
15
  interface NamespaceNotFound {
16
16
  /** package.json file path. */
17
- 'filePath'?: string | undefined | null;
17
+ filePath?: string | undefined | null;
18
18
  }
19
19
  interface NamespaceNotFoundSchema extends SpruceSchema.Schema {
20
20
  id: 'namespaceNotFound';
@@ -22,7 +22,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
22
22
  name: 'Namespace not found';
23
23
  fields: {
24
24
  /** package.json file path. */
25
- 'filePath': {
25
+ filePath: {
26
26
  label: 'package.json file path';
27
27
  type: 'text';
28
28
  options: undefined;
@@ -42,10 +42,10 @@ export declare namespace SpruceErrors.HeartwoodPolish {
42
42
  }
43
43
  type MissingAssertionEntity = SchemaEntity<SpruceErrors.HeartwoodPolish.MissingAssertionSchema>;
44
44
  }
45
- import * as Polish from "../../polish.types";
45
+ import * as Polish from '../../polish.types';
46
46
  export declare namespace SpruceErrors.HeartwoodPolish {
47
47
  interface InvalidTarget {
48
- 'target': (Polish.PolishTarget);
48
+ target: Polish.PolishTarget;
49
49
  }
50
50
  interface InvalidTargetSchema extends SpruceSchema.Schema {
51
51
  id: 'invalidTarget';
@@ -53,7 +53,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
53
53
  name: 'Invalid target';
54
54
  fields: {
55
55
  /** . */
56
- 'target': {
56
+ target: {
57
57
  type: 'raw';
58
58
  isRequired: true;
59
59
  options: {
@@ -78,7 +78,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
78
78
  export declare namespace SpruceErrors.HeartwoodPolish {
79
79
  interface InvalidAssertName {
80
80
  /** Name. */
81
- 'name': string;
81
+ name: string;
82
82
  }
83
83
  interface InvalidAssertNameSchema extends SpruceSchema.Schema {
84
84
  id: 'invalidAssertName';
@@ -86,7 +86,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
86
86
  name: 'invalid assert name';
87
87
  fields: {
88
88
  /** Name. */
89
- 'name': {
89
+ name: {
90
90
  label: 'Name';
91
91
  type: 'text';
92
92
  isRequired: true;
@@ -98,8 +98,8 @@ export declare namespace SpruceErrors.HeartwoodPolish {
98
98
  }
99
99
  export declare namespace SpruceErrors.HeartwoodPolish {
100
100
  interface InvalidActionName {
101
- 'name': string;
102
- 'validNames': string[];
101
+ name: string;
102
+ validNames: string[];
103
103
  }
104
104
  interface InvalidActionNameSchema extends SpruceSchema.Schema {
105
105
  id: 'invalidActionName';
@@ -107,13 +107,13 @@ export declare namespace SpruceErrors.HeartwoodPolish {
107
107
  name: 'Invalid action name';
108
108
  fields: {
109
109
  /** . */
110
- 'name': {
110
+ name: {
111
111
  type: 'text';
112
112
  isRequired: true;
113
113
  options: undefined;
114
114
  };
115
115
  /** . */
116
- 'validNames': {
116
+ validNames: {
117
117
  type: 'text';
118
118
  isRequired: true;
119
119
  isArray: true;
@@ -126,7 +126,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
126
126
  export declare namespace SpruceErrors.HeartwoodPolish {
127
127
  interface FileNotFound {
128
128
  /** Missing File. */
129
- 'filePath': string;
129
+ filePath: string;
130
130
  }
131
131
  interface FileNotFoundSchema extends SpruceSchema.Schema {
132
132
  id: 'fileNotFound';
@@ -134,7 +134,7 @@ export declare namespace SpruceErrors.HeartwoodPolish {
134
134
  name: 'file not found';
135
135
  fields: {
136
136
  /** Missing File. */
137
- 'filePath': {
137
+ filePath: {
138
138
  label: 'Missing File';
139
139
  type: 'text';
140
140
  isRequired: true;
@@ -1,4 +1,2 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-namespace */
3
- /* eslint-disable no-redeclare */
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,7 +5,7 @@ const assertionFailedSchema = {
5
5
  id: 'assertionFailed',
6
6
  namespace: 'HeartwoodPolish',
7
7
  name: 'Assertion failed',
8
- fields: {}
8
+ fields: {},
9
9
  };
10
10
  schema_1.SchemaRegistry.getInstance().trackSchema(assertionFailedSchema);
11
11
  exports.default = assertionFailedSchema;
@@ -7,13 +7,13 @@ const fileNotFoundSchema = {
7
7
  name: 'file not found',
8
8
  fields: {
9
9
  /** Missing File. */
10
- 'filePath': {
10
+ filePath: {
11
11
  label: 'Missing File',
12
12
  type: 'text',
13
13
  isRequired: true,
14
- options: undefined
14
+ options: undefined,
15
15
  },
16
- }
16
+ },
17
17
  };
18
18
  schema_1.SchemaRegistry.getInstance().trackSchema(fileNotFoundSchema);
19
19
  exports.default = fileNotFoundSchema;
@@ -7,19 +7,19 @@ const invalidActionNameSchema = {
7
7
  name: 'Invalid action name',
8
8
  fields: {
9
9
  /** . */
10
- 'name': {
10
+ name: {
11
11
  type: 'text',
12
12
  isRequired: true,
13
- options: undefined
13
+ options: undefined,
14
14
  },
15
15
  /** . */
16
- 'validNames': {
16
+ validNames: {
17
17
  type: 'text',
18
18
  isRequired: true,
19
19
  isArray: true,
20
- options: undefined
20
+ options: undefined,
21
21
  },
22
- }
22
+ },
23
23
  };
24
24
  schema_1.SchemaRegistry.getInstance().trackSchema(invalidActionNameSchema);
25
25
  exports.default = invalidActionNameSchema;
@@ -7,13 +7,13 @@ const invalidAssertNameSchema = {
7
7
  name: 'invalid assert name',
8
8
  fields: {
9
9
  /** Name. */
10
- 'name': {
10
+ name: {
11
11
  label: 'Name',
12
12
  type: 'text',
13
13
  isRequired: true,
14
- options: undefined
14
+ options: undefined,
15
15
  },
16
- }
16
+ },
17
17
  };
18
18
  schema_1.SchemaRegistry.getInstance().trackSchema(invalidAssertNameSchema);
19
19
  exports.default = invalidAssertNameSchema;
@@ -5,7 +5,7 @@ const invalidStepSchema = {
5
5
  id: 'invalidStep',
6
6
  namespace: 'HeartwoodPolish',
7
7
  name: 'Invalid step',
8
- fields: {}
8
+ fields: {},
9
9
  };
10
10
  schema_1.SchemaRegistry.getInstance().trackSchema(invalidStepSchema);
11
11
  exports.default = invalidStepSchema;
@@ -7,12 +7,12 @@ const invalidTargetSchema = {
7
7
  name: 'Invalid target',
8
8
  fields: {
9
9
  /** . */
10
- 'target': {
10
+ target: {
11
11
  type: 'raw',
12
12
  isRequired: true,
13
- options: { valueType: `Polish.PolishTarget`, }
13
+ options: { valueType: `Polish.PolishTarget` },
14
14
  },
15
- }
15
+ },
16
16
  };
17
17
  schema_1.SchemaRegistry.getInstance().trackSchema(invalidTargetSchema);
18
18
  exports.default = invalidTargetSchema;
@@ -5,7 +5,7 @@ const missingAssertionSchema = {
5
5
  id: 'missingAssertion',
6
6
  namespace: 'HeartwoodPolish',
7
7
  name: 'missing assertion',
8
- fields: {}
8
+ fields: {},
9
9
  };
10
10
  schema_1.SchemaRegistry.getInstance().trackSchema(missingAssertionSchema);
11
11
  exports.default = missingAssertionSchema;
@@ -7,12 +7,12 @@ const namespaceNotFoundSchema = {
7
7
  name: 'Namespace not found',
8
8
  fields: {
9
9
  /** package.json file path. */
10
- 'filePath': {
10
+ filePath: {
11
11
  label: 'package.json file path',
12
12
  type: 'text',
13
- options: undefined
13
+ options: undefined,
14
14
  },
15
- }
15
+ },
16
16
  };
17
17
  schema_1.SchemaRegistry.getInstance().trackSchema(namespaceNotFoundSchema);
18
18
  exports.default = namespaceNotFoundSchema;
@@ -5,7 +5,7 @@ const tooManyPolishFilesSchema = {
5
5
  id: 'tooManyPolishFiles',
6
6
  namespace: 'HeartwoodPolish',
7
7
  name: 'too many polish files',
8
- fields: {}
8
+ fields: {},
9
9
  };
10
10
  schema_1.SchemaRegistry.getInstance().trackSchema(tooManyPolishFilesSchema);
11
11
  exports.default = tooManyPolishFilesSchema;
@@ -1,5 +1,5 @@
1
+ import { ErrorOptions as ISpruceErrorOptions } from '@sprucelabs/error';
1
2
  import { SpruceErrors } from "./errors.types";
2
- import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
3
3
  export interface TooManyPolishFilesErrorOptions extends SpruceErrors.HeartwoodPolish.TooManyPolishFiles, ISpruceErrorOptions {
4
4
  code: 'TOO_MANY_POLISH_FILES';
5
5
  }
@@ -1 +1 @@
1
- export { FieldDefinitions, FieldDefinitionMap, FieldValueTypeGeneratorMap, FieldMap } from '@sprucelabs/schema';
1
+ export { FieldDefinitions, FieldDefinitionMap, FieldValueTypeGeneratorMap, FieldMap, } from '@sprucelabs/schema';
@@ -8,7 +8,7 @@ class SpruceError extends error_1.default {
8
8
  friendlyMessage() {
9
9
  const { options } = this;
10
10
  let message;
11
- switch (options === null || options === void 0 ? void 0 : options.code) {
11
+ switch (options?.code) {
12
12
  case 'INVALID_TARGET':
13
13
  message = `The target you passed was invalid! You passed:\n\n${JSON.stringify(options.target, undefined, 4)}`;
14
14
  break;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
7
7
  class StepGenerator {
8
+ actions;
8
9
  constructor(actions) {
9
10
  this.actions = actions;
10
11
  }
@@ -10,8 +10,14 @@ const schema_1 = require("@sprucelabs/schema");
10
10
  const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
11
11
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
12
12
  class StepLoader {
13
+ cwd;
14
+ packageJsonPath;
15
+ namespace;
16
+ polishFile;
17
+ glob;
18
+ static divider = '## HEARTWOOD-POLISH DIVIDER ##';
19
+ static errorDivider = '## HEARTWOOD-POLISH ERROR DIVIDER ##';
13
20
  constructor(options) {
14
- var _a;
15
21
  const { cwd } = (0, schema_1.assertOptions)(options, ['cwd']);
16
22
  this.cwd = cwd;
17
23
  this.packageJsonPath = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'package.json');
@@ -30,7 +36,7 @@ class StepLoader {
30
36
  });
31
37
  }
32
38
  const content = require(this.packageJsonPath);
33
- if (!((_a = content === null || content === void 0 ? void 0 : content.skill) === null || _a === void 0 ? void 0 : _a.namespace)) {
39
+ if (!content?.skill?.namespace) {
34
40
  throw new SpruceError_1.default({
35
41
  code: 'NAMESPACE_NOT_FOUND',
36
42
  friendlyMessage: `I could not find a skill.namespace in '${this.packageJsonPath}'`,
@@ -40,7 +46,7 @@ class StepLoader {
40
46
  this.namespace = content.skill.namespace;
41
47
  }
42
48
  async load(altNamespace) {
43
- this.glob = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'src', '**', `${altNamespace !== null && altNamespace !== void 0 ? altNamespace : this.namespace}.polish.ts`);
49
+ this.glob = spruce_skill_utils_1.diskUtil.resolvePath(this.cwd, 'src', '**', `${altNamespace ?? this.namespace}.polish.ts`);
44
50
  const matches = this.glob ? await (0, globby_1.default)(this.glob) : [];
45
51
  if (matches.length === 0) {
46
52
  throw new SpruceError_1.default({
@@ -82,28 +88,28 @@ class StepLoader {
82
88
  }
83
89
  static async execute(cmd, args) {
84
90
  return new Promise((resolve, reject) => {
85
- var _a, _b;
86
91
  let stdout = '';
87
92
  let stderr = '';
88
93
  const child = (0, child_process_1.spawn)(cmd, args, {
89
94
  shell: true,
90
95
  });
91
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.addListener('data', (data) => {
96
+ child.stdout?.addListener('data', (data) => {
92
97
  stdout += data;
93
98
  });
94
- (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.addListener('data', (data) => {
99
+ child.stderr?.addListener('data', (data) => {
95
100
  stderr += data;
96
101
  });
97
102
  const closeHandler = (code) => {
98
103
  setTimeout(() => {
99
- var _a, _b;
100
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
101
- (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
104
+ child.stdout?.removeAllListeners();
105
+ child.stderr?.removeAllListeners();
102
106
  child.removeAllListeners();
103
107
  if (code === 0) {
104
108
  stdout = stdout.replace(StepLoader.divider, '').trim();
105
109
  if (stdout.search(StepLoader.errorDivider) > -1) {
106
- stdout = stdout.replace(StepLoader.errorDivider, '').trim();
110
+ stdout = stdout
111
+ .replace(StepLoader.errorDivider, '')
112
+ .trim();
107
113
  reject({ stdout });
108
114
  }
109
115
  else {
@@ -121,5 +127,3 @@ class StepLoader {
121
127
  }
122
128
  }
123
129
  exports.StepLoader = StepLoader;
124
- StepLoader.divider = '## HEARTWOOD-POLISH DIVIDER ##';
125
- StepLoader.errorDivider = '## HEARTWOOD-POLISH ERROR DIVIDER ##';
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_1 = require("@sprucelabs/schema");
4
4
  const TargetSelectorGenerator_1 = require("../targeting/TargetSelectorGenerator");
5
5
  class AbstractAction {
6
+ page;
7
+ baseUrl;
8
+ targets;
6
9
  constructor(page, baseUrl) {
7
10
  (0, schema_1.assertOptions)({ page, baseUrl }, ['page', 'baseUrl']);
8
11
  this.page = page;
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const schema_1 = require("@sprucelabs/schema");
7
7
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
8
8
  class ActionFactory {
9
+ page;
10
+ static actionMap = {};
11
+ baseUrl;
9
12
  static setAction(name, Class) {
10
13
  this.actionMap[name] = Class;
11
14
  }
@@ -26,5 +29,4 @@ class ActionFactory {
26
29
  return new Class(this.page, this.baseUrl);
27
30
  }
28
31
  }
29
- ActionFactory.actionMap = {};
30
32
  exports.default = ActionFactory;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
@@ -19,6 +8,11 @@ const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
19
8
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
20
9
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
21
10
  class AssertAction extends AbstractAction_1.default {
11
+ static assertions = {};
12
+ assertName;
13
+ target;
14
+ options;
15
+ originalTarget;
22
16
  static addAssertion(name, cb) {
23
17
  this.assertions[name] = cb;
24
18
  }
@@ -27,7 +21,7 @@ class AssertAction extends AbstractAction_1.default {
27
21
  return !!this.assertions[name];
28
22
  }
29
23
  process(options) {
30
- const { target } = options, rest = __rest(options, ["target"]);
24
+ const { target, ...rest } = options;
31
25
  const name = Object.keys(rest)[0];
32
26
  this.assertName = name;
33
27
  this.getAction();
@@ -47,13 +41,19 @@ class AssertAction extends AbstractAction_1.default {
47
41
  return action;
48
42
  }
49
43
  async go() {
50
- await this.getAction()(Object.assign(Object.assign({}, this.options), { targetSelector: this.target, originalTarget: this.originalTarget, getProperty: (selector, name) => this.getProperty(selector, name), getInnerHtml: (selector) => this.getInnerHtml(selector), page: this.page }));
44
+ await this.getAction()({
45
+ ...this.options,
46
+ targetSelector: this.target,
47
+ originalTarget: this.originalTarget,
48
+ getProperty: (selector, name) => this.getProperty(selector, name),
49
+ getInnerHtml: (selector) => this.getInnerHtml(selector),
50
+ page: this.page,
51
+ });
51
52
  }
52
53
  async getProperty(selector, name) {
53
- var _a;
54
54
  const element = await this.page.$(selector);
55
- const prop = await (element === null || element === void 0 ? void 0 : element.getProperty(name));
56
- const actual = await ((_a = prop === null || prop === void 0 ? void 0 : prop.jsonValue) === null || _a === void 0 ? void 0 : _a.call(prop));
55
+ const prop = await element?.getProperty(name);
56
+ const actual = await prop?.jsonValue?.();
57
57
  return actual;
58
58
  }
59
59
  async getInnerHtml(selector) {
@@ -61,5 +61,4 @@ class AssertAction extends AbstractAction_1.default {
61
61
  }
62
62
  }
63
63
  exports.AssertAction = AssertAction;
64
- AssertAction.assertions = {};
65
64
  ActionFactory_1.default.setAction('assert', AssertAction);
@@ -8,6 +8,7 @@ const AbstractAction_1 = __importDefault(require("./AbstractAction"));
8
8
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
9
9
  const clearField_1 = require("./clearField");
10
10
  class ClearTextAction extends AbstractAction_1.default {
11
+ target;
11
12
  process(options) {
12
13
  this.target = this.targets.generate(options.target);
13
14
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
7
7
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
8
8
  class ClickAction extends AbstractAction_1.default {
9
+ targetSelector;
9
10
  process(options) {
10
11
  this.targetSelector = this.targets.generate(options.target);
11
12
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
7
7
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
8
8
  class ConfigureAction extends AbstractAction_1.default {
9
+ stepWaitMs;
9
10
  process(options) {
10
11
  const { stepWaitMs } = options;
11
12
  this.stepWaitMs = stepWaitMs;
@@ -7,6 +7,8 @@ const schema_1 = require("@sprucelabs/schema");
7
7
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
8
8
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
9
9
  class DragAndDropAction extends AbstractAction_1.default {
10
+ destinationSelector;
11
+ sourceSelector;
10
12
  process(options) {
11
13
  const { sourceTarget, destinationTarget } = (0, schema_1.assertOptions)(options, [
12
14
  'sourceTarget',
@@ -19,7 +21,7 @@ class DragAndDropAction extends AbstractAction_1.default {
19
21
  const source = await this.waitForSelector(this.sourceSelector);
20
22
  const destination = await this.waitForSelector(this.destinationSelector);
21
23
  const sourceBox = await source.boundingBox();
22
- const destinationBox = await (destination === null || destination === void 0 ? void 0 : destination.boundingBox());
24
+ const destinationBox = await destination?.boundingBox();
23
25
  await this.page.mouse.move(sourceBox.x + sourceBox.width / 2, sourceBox.y + sourceBox.height / 2);
24
26
  await this.page.mouse.down();
25
27
  await this.page.mouse.move(destinationBox.x + destinationBox.width / 2, destinationBox.y + destinationBox.height / 2, {
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
7
7
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
8
8
  class FileAction extends AbstractAction_1.default {
9
+ targetSelector;
10
+ target;
11
+ absoluteFilePath;
9
12
  process(options) {
10
13
  const { target, absoluteFilePath } = options;
11
14
  this.target = this.targets.generate(target);
@@ -13,7 +16,7 @@ class FileAction extends AbstractAction_1.default {
13
16
  }
14
17
  async go() {
15
18
  const element = await this.page.$(this.target);
16
- await (element === null || element === void 0 ? void 0 : element.uploadFile(this.absoluteFilePath));
19
+ await element?.uploadFile(this.absoluteFilePath);
17
20
  }
18
21
  }
19
22
  exports.default = FileAction;
@@ -7,6 +7,7 @@ const schema_1 = require("@sprucelabs/schema");
7
7
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
8
8
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
9
9
  class RedirectAction extends AbstractAction_1.default {
10
+ destinationId;
10
11
  process(options) {
11
12
  const { id } = (0, schema_1.assertOptions)(options, ['id']);
12
13
  this.destinationId = id;
@@ -14,7 +15,8 @@ class RedirectAction extends AbstractAction_1.default {
14
15
  async go() {
15
16
  const destination = this.baseUrl + `/#views/${this.destinationId}`;
16
17
  await this.page.goto(destination);
17
- const selector = '.' + this.destinationId.replace(/[^A-Za-z0-9]/, '_').replace('__*', '_');
18
+ const selector = '.' +
19
+ this.destinationId.replace(/[^A-Za-z0-9]/, '_').replace('__*', '_');
18
20
  await this.page.waitForSelector(selector);
19
21
  await this.page.waitForTimeout(500);
20
22
  }
@@ -8,6 +8,8 @@ const schema_1 = require("@sprucelabs/schema");
8
8
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
9
9
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
10
10
  class SelectAction extends AbstractAction_1.default {
11
+ value;
12
+ selectSelector;
11
13
  process(options) {
12
14
  const { value, target } = (0, schema_1.assertOptions)(options, ['target', 'value']);
13
15
  this.value = value;
@@ -8,11 +8,13 @@ const AbstractAction_1 = __importDefault(require("./AbstractAction"));
8
8
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
9
9
  const clearField_1 = require("./clearField");
10
10
  class TypeTextAction extends AbstractAction_1.default {
11
+ selector;
12
+ text;
13
+ shouldClearFirst;
11
14
  process(options) {
12
- var _a;
13
15
  this.selector = this.targets.generate(options.target);
14
16
  this.text = options.text;
15
- this.shouldClearFirst = (_a = options.shouldClearFirst) !== null && _a !== void 0 ? _a : false;
17
+ this.shouldClearFirst = options.shouldClearFirst ?? false;
16
18
  }
17
19
  async go() {
18
20
  await this.waitForSelector(this.selector);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const AbstractAction_1 = __importDefault(require("./AbstractAction"));
7
7
  const ActionFactory_1 = __importDefault(require("./ActionFactory"));
8
8
  class WaitAction extends AbstractAction_1.default {
9
+ waitMs;
9
10
  process(options) {
10
11
  const { waitMs } = options;
11
12
  this.waitMs = waitMs;
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const SpruceError_1 = __importDefault(require("../../errors/SpruceError"));
7
7
  const AssertAction_1 = require("../AssertAction");
8
8
  async function assertDoesNotInclude(options) {
9
- var _a;
10
9
  const { targetSelector, value, getInnerHtml } = options;
11
- const actual = (_a = (await getInnerHtml(targetSelector))) !== null && _a !== void 0 ? _a : '';
10
+ const actual = (await getInnerHtml(targetSelector)) ?? '';
12
11
  const foundIdx = actual.indexOf(value);
13
12
  if (foundIdx > -1) {
14
13
  throw new SpruceError_1.default({
@@ -35,7 +35,7 @@ async function assertPresentSlide(options) {
35
35
  if (hasSlideNumber) {
36
36
  const selector = `${targetSelector} .swipe_dots_wrapper span.dot:nth-of-type(${slideIdx + 1}).current`;
37
37
  const className = await getProperty(selector, 'className');
38
- if ((className !== null && className !== void 0 ? className : '').length === 0) {
38
+ if ((className ?? '').length === 0) {
39
39
  throw new SpruceError_1.default({
40
40
  code: 'ASSERTION_FAILED',
41
41
  friendlyMessage: `I expected to find the 'current' slide as slide #${slideIdx}. I was looking for ${selector}.`,
package/build/polish.js CHANGED
@@ -27,7 +27,6 @@ void (async () => {
27
27
  await go();
28
28
  })();
29
29
  async function go() {
30
- var _a;
31
30
  const stepLoader = new StepLoader_1.StepLoader({
32
31
  cwd: process.cwd(),
33
32
  });
@@ -35,7 +34,9 @@ async function go() {
35
34
  const browser = await puppeteer_1.default.launch({
36
35
  headless: getIsHeadless(),
37
36
  args: ['--no-sandbox', '--disable-setuid-sandbox', '--start-maximized'],
38
- defaultViewport: Object.assign({}, getWindowSize()),
37
+ defaultViewport: {
38
+ ...getWindowSize(),
39
+ },
39
40
  });
40
41
  const page = (await browser.newPage());
41
42
  page.waitForTimeout = async (ms) => {
@@ -53,7 +54,7 @@ async function go() {
53
54
  });
54
55
  }
55
56
  catch (err) {
56
- if ((_a = err === null || err === void 0 ? void 0 : err.options) === null || _a === void 0 ? void 0 : _a.friendlyMessage) {
57
+ if (err?.options?.friendlyMessage) {
57
58
  console.log('Error: ' + err.options.friendlyMessage);
58
59
  }
59
60
  else {
@@ -65,21 +66,21 @@ async function go() {
65
66
  }
66
67
  }
67
68
  function getNamespace() {
68
- return argv === null || argv === void 0 ? void 0 : argv.namespace;
69
+ return argv?.namespace;
69
70
  }
70
71
  function getBaseUrl() {
71
- return process.env.POLISH_BASE_URL || (argv === null || argv === void 0 ? void 0 : argv.baseUrl) || 'https://spruce.bot';
72
+ return process.env.POLISH_BASE_URL || argv?.baseUrl || 'https://spruce.bot';
72
73
  }
73
74
  function getIsHeadless() {
74
75
  return process.env.HEADLESS
75
76
  ? process.env.HEADLESS !== 'false'
76
- : (argv === null || argv === void 0 ? void 0 : argv.isHeadless) === 'true';
77
+ : argv?.isHeadless === 'true';
77
78
  }
78
79
  function getWindowSize() {
79
80
  const str = process.env.WINDOW_SIZE
80
81
  ? process.env.WINDOW_SIZE
81
- : argv === null || argv === void 0 ? void 0 : argv.windowSize;
82
- const [width, height] = (str !== null && str !== void 0 ? str : '1024,768').split(',');
82
+ : argv?.windowSize;
83
+ const [width, height] = (str ?? '1024,768').split(',');
83
84
  return {
84
85
  width: parseInt(width, 10),
85
86
  height: parseInt(height, 10),
@@ -2,12 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_1 = require("@sprucelabs/schema");
4
4
  class Polisher {
5
+ page;
6
+ log;
7
+ stepWaitMs = 250;
5
8
  constructor(options) {
6
- this.stepWaitMs = 250;
7
- const { page, log, stepWaitMs } = (0, schema_1.assertOptions)(options, ['page', 'log']);
9
+ const { page, log, stepWaitMs } = (0, schema_1.assertOptions)(options, [
10
+ 'page',
11
+ 'log',
12
+ ]);
8
13
  this.page = page;
9
14
  this.log = log;
10
- this.stepWaitMs = stepWaitMs !== null && stepWaitMs !== void 0 ? stepWaitMs : this.stepWaitMs;
15
+ this.stepWaitMs = stepWaitMs ?? this.stepWaitMs;
11
16
  this.page.on('console', (msg) => this.log.info(msg.text()));
12
17
  }
13
18
  async start(url, steps) {
@@ -6,50 +6,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TargetSelectorGenerator = void 0;
7
7
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
8
8
  class TargetSelectorGenerator {
9
- constructor() {
10
- this.componentSelectorMap = {
11
- Button: '.button',
12
- Toggle: 'button.toggle',
13
- Card: '.card',
14
- Calendar: '.bigcalendar',
15
- Dialog: '.dialog ',
16
- Field: '',
17
- ListRow: '.list__row',
18
- NavLink: '.dropdown button',
19
- NavMenu: 'nav ',
20
- SkillView: '.skill_view',
21
- ToolBelt: '.tool_belt__inner_column',
22
- Tool: '.tool',
23
- Dropdown: '.dropdown.visible',
24
- DrodownItem: 'li',
25
- ToolBeltTab: '.tool_belt__column .tab button',
26
- ListCell: '.list__cell',
27
- Checkbox: '[type="checkbox"]',
28
- CalendarTime: '.timeslot',
29
- CalendarTeammate: '.bigcalendar__day-col-visible',
30
- CalendarEvent: '.bigcalendar__event',
31
- CalendarEventSDrag: '.resize-s',
32
- CalendarEventNDrag: '.resize-n',
33
- CalendarDay: '.days li',
34
- };
35
- this.selectorStringMap = {
36
- Field: (id) => ` [name="${id}"]`,
37
- Card: (id) => `[data-id="${id}"]`,
38
- Tool: (id) => `[data-id="${id}"]`,
39
- ToolBelt: (id) => `[data-id="${id}"]`,
40
- CalendarTime: (id) => `[data-time="${id}"]`,
41
- CalendarDay: (id) => `[data-date="${id}"]`,
42
- ListRow: (id) => `.row_${id}`,
43
- Button: (id) => id === 'primary' || id === 'secondary' ? `.${id}` : `.btn_${id}`,
44
- NavLink: (id) => `.btn_${id}`,
45
- _default: (id) => `.${id}`,
46
- };
47
- this.selectorNumberMap = {
48
- DrodownItem: (id) => `:nth-of-type(${+id + 1}) button`,
49
- _default: (id) => `:nth-of-type(${+id + 1})`,
50
- CalendarEvent: (id) => `:nth-of-type(${+id + 2})`,
51
- };
52
- }
9
+ componentSelectorMap = {
10
+ Button: '.button',
11
+ Toggle: 'button.toggle',
12
+ Card: '.card',
13
+ Calendar: '.bigcalendar',
14
+ Dialog: '.dialog ',
15
+ Field: '',
16
+ ListRow: '.list__row',
17
+ NavLink: '.dropdown button',
18
+ NavMenu: 'nav ',
19
+ SkillView: '.skill_view',
20
+ ToolBelt: '.tool_belt__inner_column',
21
+ Tool: '.tool',
22
+ Dropdown: '.dropdown.visible',
23
+ DrodownItem: 'li',
24
+ ToolBeltTab: '.tool_belt__column .tab button',
25
+ ListCell: '.list__cell',
26
+ Checkbox: '[type="checkbox"]',
27
+ CalendarTime: '.timeslot',
28
+ CalendarTeammate: '.bigcalendar__day-col-visible',
29
+ CalendarEvent: '.bigcalendar__event',
30
+ CalendarEventSDrag: '.resize-s',
31
+ CalendarEventNDrag: '.resize-n',
32
+ CalendarDay: '.days li',
33
+ };
34
+ selectorStringMap = {
35
+ Field: (id) => ` [name="${id}"]`,
36
+ Card: (id) => `[data-id="${id}"]`,
37
+ Tool: (id) => `[data-id="${id}"]`,
38
+ ToolBelt: (id) => `[data-id="${id}"]`,
39
+ CalendarTime: (id) => `[data-time="${id}"]`,
40
+ CalendarDay: (id) => `[data-date="${id}"]`,
41
+ ListRow: (id) => `.row_${id}`,
42
+ Button: (id) => id === 'primary' || id === 'secondary' ? `.${id}` : `.btn_${id}`,
43
+ NavLink: (id) => `.btn_${id}`,
44
+ _default: (id) => `.${id}`,
45
+ };
46
+ selectorNumberMap = {
47
+ DrodownItem: (id) => `:nth-of-type(${+id + 1}) button`,
48
+ _default: (id) => `:nth-of-type(${+id + 1})`,
49
+ CalendarEvent: (id) => `:nth-of-type(${+id + 2})`,
50
+ };
53
51
  generate(target) {
54
52
  const match = target
55
53
  .map((t) => {
@@ -97,13 +95,11 @@ class TargetSelectorGenerator {
97
95
  return match;
98
96
  }
99
97
  generateSelectorSuffixFromString(component, id) {
100
- var _a;
101
- const map = (_a = this.selectorStringMap[component]) !== null && _a !== void 0 ? _a : this.selectorStringMap._default;
98
+ const map = this.selectorStringMap[component] ?? this.selectorStringMap._default;
102
99
  return map(id);
103
100
  }
104
101
  generateSelectorSuffixFromNumber(component, id) {
105
- var _a;
106
- const map = (_a = this.selectorNumberMap[component]) !== null && _a !== void 0 ? _a : this.selectorNumberMap._default;
102
+ const map = this.selectorNumberMap[component] ?? this.selectorNumberMap._default;
107
103
  return map(id);
108
104
  }
109
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprucelabs/heartwood-polish",
3
- "version": "6.3.480",
3
+ "version": "7.0.0",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "access": "public",
@@ -27,8 +27,8 @@
27
27
  "clean.all": "yarn clean.dependencies && yarn clean.build",
28
28
  "clean.build": "rm -rf build/",
29
29
  "clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
30
- "fix.lint": "eslint --fix --cache '**/*.ts'",
31
- "lint": "eslint --cache '**/*.ts'",
30
+ "fix.lint": "eslint --fix --cache",
31
+ "lint": "eslint --cache",
32
32
  "lint.tsc": "tsc -p . --noEmit",
33
33
  "post.watch.build": "yarn build.copy-files && yarn build.resolve-paths",
34
34
  "release": "semantic-release",
@@ -44,35 +44,35 @@
44
44
  "watch.tsc": "tsc -w"
45
45
  },
46
46
  "dependencies": {
47
- "@sprucelabs/error": "^5.1.108",
48
- "@sprucelabs/globby": "^1.0.32",
49
- "@sprucelabs/schema": "^29.4.60",
47
+ "@sprucelabs/error": "^6.0.1",
48
+ "@sprucelabs/globby": "^2.0.1",
49
+ "@sprucelabs/schema": "^30.0.0",
50
50
  "@sprucelabs/spruce-core-schemas": "^39.0.294",
51
- "@sprucelabs/spruce-skill-utils": "^30.4.29",
52
- "puppeteer": "^22.6.2",
51
+ "@sprucelabs/spruce-skill-utils": "^31.0.0",
52
+ "puppeteer": "^22.6.5",
53
53
  "yargs": "^17.7.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@sprucelabs/jest-json-reporter": "^7.0.207",
57
57
  "@sprucelabs/jest-sheets-reporter": "^3.0.26",
58
58
  "@sprucelabs/resolve-path-aliases": "^1.1.304",
59
- "@sprucelabs/semantic-release": "^4.0.8",
60
- "@sprucelabs/spruce-test-fixtures": "^61.1.33",
61
- "@sprucelabs/test": "^8.0.50",
62
- "@sprucelabs/test-utils": "^4.0.157",
63
- "@types/node": "^20.12.4",
59
+ "@sprucelabs/semantic-release": "^5.0.1",
60
+ "@sprucelabs/spruce-test-fixtures": "^61.1.35",
61
+ "@sprucelabs/test": "^9.0.2",
62
+ "@sprucelabs/test-utils": "^5.0.1",
63
+ "@types/node": "^20.12.7",
64
64
  "chokidar-cli": "^3.0.0",
65
65
  "concurrently": "^8.2.2",
66
- "devtools-protocol": "^0.0.1282316",
67
- "eslint": "^8.57.0",
68
- "eslint-config-spruce": "^10.13.6",
66
+ "devtools-protocol": "^0.0.1286932",
67
+ "eslint": "^9.0.0",
68
+ "eslint-config-spruce": "^11.2.5",
69
69
  "jest": "^29.7.0",
70
70
  "jest-circus": "^29.7.0",
71
71
  "prettier": "^3.2.5",
72
72
  "ts-node": "^10.9.2",
73
73
  "tsc-watch": "^6.2.0",
74
74
  "tsconfig-paths": "^4.2.0",
75
- "typescript": "^5.4.4"
75
+ "typescript": "^5.4.5"
76
76
  },
77
77
  "jest": {
78
78
  "testRunner": "jest-circus/runner",
package/tsconfig.json CHANGED
@@ -3,11 +3,10 @@
3
3
  "skipLibCheck": true,
4
4
  "module": "commonjs",
5
5
  "esModuleInterop": true,
6
- "target": "ES2017",
6
+ "target": "ES2022",
7
7
  "lib": [
8
8
  "DOM",
9
- "es2017",
10
- "ES2020"
9
+ "ES2022"
11
10
  ],
12
11
  "declaration": true,
13
12
  "noImplicitAny": true,
@@ -37,4 +36,4 @@
37
36
  "build",
38
37
  "esm"
39
38
  ]
40
- }
39
+ }