-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from axhxrx/1-cannot-publish-due-to-jsr-compati…
…bility-issues 🔧 fix: give Windsurf another crack at dealing with JSR's restrictions… PART II THE EXCITING SEQUEL
- Loading branch information
Showing
8 changed files
with
66 additions
and
27 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,11 +1,17 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
import { ValidatedString, type ValidatedStringFactory } from './ValidatedString.ts'; | ||
|
||
const isAlphabeticOrUnderscore = (s: string): boolean => /^[a-zA-Z_]+$/.test(s); | ||
|
||
/** | ||
Why JSRCompatibleFactory? See https://github.com/axhxrx/validated-string/issues/1 — consumers of this lib probably don't need to deal with this | ||
*/ | ||
const JSRCompatibleFactory = ValidatedString.create(isAlphabeticOrUnderscore, { | ||
name: 'AlphabeticOrUnderscoreString', | ||
description: 'must contain only letters (A-Z, a-z) or underscores', | ||
}); | ||
|
||
export type AlphabeticOrUnderscoreString = typeof JSRCompatibleFactory.type; | ||
export const AlphabeticOrUnderscoreString = JSRCompatibleFactory.factory; | ||
const type: ValidatedString<typeof isAlphabeticOrUnderscore> = JSRCompatibleFactory.type; | ||
const factory: ValidatedStringFactory<typeof isAlphabeticOrUnderscore> = JSRCompatibleFactory.factory; | ||
|
||
export type AlphabeticOrUnderscoreString = typeof type; | ||
export const AlphabeticOrUnderscoreString = factory; |
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,11 +1,17 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
import { ValidatedString, type ValidatedStringFactory } from './ValidatedString.ts'; | ||
|
||
const isAlphabetic = (s: string): boolean => /^[a-zA-Z]+$/.test(s); | ||
|
||
/** | ||
Why JSRCompatibleFactory? See https://github.com/axhxrx/validated-string/issues/1 — consumers of this lib probably don't need to deal with this | ||
*/ | ||
const JSRCompatibleFactory = ValidatedString.create(isAlphabetic, { | ||
name: 'AlphabeticString', | ||
description: 'must contain only letters (A-Z, a-z)', | ||
}); | ||
|
||
export type AlphabeticString = typeof JSRCompatibleFactory.type; | ||
export const AlphabeticString = JSRCompatibleFactory.factory; | ||
const type: ValidatedString<typeof isAlphabetic> = JSRCompatibleFactory.type; | ||
const factory: ValidatedStringFactory<typeof isAlphabetic> = JSRCompatibleFactory.factory; | ||
|
||
export type AlphabeticString = typeof type; | ||
export const AlphabeticString = factory; |
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,11 +1,17 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
import { ValidatedString, type ValidatedStringFactory } from './ValidatedString.ts'; | ||
|
||
const isLowercaseAlpha = (s: string): boolean => /^[a-z]+$/.test(s); | ||
|
||
/** | ||
Why JSRCompatibleFactory? See https://github.com/axhxrx/validated-string/issues/1 — consumers of this lib probably don't need to deal with this | ||
*/ | ||
const JSRCompatibleFactory = ValidatedString.create(isLowercaseAlpha, { | ||
name: 'LowercaseAlphabeticString', | ||
description: 'must contain only lowercase letters (a-z)', | ||
}); | ||
|
||
export type LowercaseAlphabeticString = typeof JSRCompatibleFactory.type; | ||
export const LowercaseAlphabeticString = JSRCompatibleFactory.factory; | ||
const type: ValidatedString<typeof isLowercaseAlpha> = JSRCompatibleFactory.type; | ||
const factory: ValidatedStringFactory<typeof isLowercaseAlpha> = JSRCompatibleFactory.factory; | ||
|
||
export type LowercaseAlphabeticString = typeof type; | ||
export const LowercaseAlphabeticString = factory; |
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,14 +1,20 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
import { ValidatedString, type ValidatedStringFactory } from './ValidatedString.ts'; | ||
|
||
const isPrometheusMetricName = (s: string): boolean => /^[a-zA-Z_:][a-zA-Z0-9_:]*$/.test(s); | ||
|
||
/** | ||
Why JSRCompatibleFactory? See https://github.com/axhxrx/validated-string/issues/1 — consumers of this lib probably don't need to deal with this | ||
*/ | ||
const JSRCompatibleFactory = ValidatedString.create(isPrometheusMetricName, { | ||
name: 'PrometheusMetricName', | ||
description: 'must start with a letter, underscore, or colon, followed by letters, digits, underscores, or colons', | ||
}); | ||
|
||
const type: ValidatedString<typeof isPrometheusMetricName> = JSRCompatibleFactory.type; | ||
const factory: ValidatedStringFactory<typeof isPrometheusMetricName> = JSRCompatibleFactory.factory; | ||
|
||
/** | ||
A validated string that represents a Prometheus metric name. See {@link ValidatedString} for more information. Note that this might not really exactly match the rules for Prometheus metric names, but it's close enough for our purposes; namely, generating metrics — don't rely on this to *validate* Prometheus metric names, as it is based on a quick skim of the Prometheus docs. | ||
*/ | ||
export type PrometheusMetricName = typeof JSRCompatibleFactory.type; | ||
export const PrometheusMetricName = JSRCompatibleFactory.factory; | ||
export type PrometheusMetricName = typeof type; | ||
export const PrometheusMetricName = factory; |
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,14 +1,21 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
import { ValidatedString, type ValidatedStringFactory } from './ValidatedString.ts'; | ||
|
||
const isPrometheusMetricNameWithoutColon = (s: string): boolean => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s); | ||
|
||
/** | ||
Why JSRCompatibleFactory? See https://github.com/axhxrx/validated-string/issues/1 — consumers of this lib probably don't need to deal with this | ||
*/ | ||
const JSRCompatibleFactory = ValidatedString.create( | ||
isPrometheusMetricNameWithoutColon, | ||
{ | ||
name: 'PrometheusMetricNameWithoutColon', | ||
description: 'must start with a letter or underscore, followed by letters, digits, or underscores', | ||
description: | ||
'must start with a letter or underscore, followed by letters, digits, or underscores', | ||
}, | ||
); | ||
|
||
export type PrometheusMetricNameWithoutColon = typeof JSRCompatibleFactory.type; | ||
export const PrometheusMetricNameWithoutColon = JSRCompatibleFactory.factory; | ||
const type: ValidatedString<typeof isPrometheusMetricNameWithoutColon> = JSRCompatibleFactory.type; | ||
const factory: ValidatedStringFactory<typeof isPrometheusMetricNameWithoutColon> = JSRCompatibleFactory.factory; | ||
|
||
export type PrometheusMetricNameWithoutColon = typeof type; | ||
export const PrometheusMetricNameWithoutColon = factory; |
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