Skip to content

Commit

Permalink
fixes some types and grammatical errors (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurvalls authored Dec 19, 2024
1 parent d605b76 commit a2eb8c1
Show file tree
Hide file tree
Showing 29 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion blocks/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ const actionBlock: Block<ActionModule> = {
};

/**
* Actions are arbitrary functions that always run in a request context, it execute mutations.
* Actions are arbitrary functions that always run in a request context, it executes mutations.
*/
export default actionBlock;
4 changes: 2 additions & 2 deletions blocks/appsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import type { AppManifest } from "../types.ts";
import { usePreviewFunc } from "./utils.tsx";

const resolverIsBlock = (blk: Block) => (resolver: string) => {
const splitted = resolver.split("/");
const segments = resolver.split("/");
// check if there's any segment on the same name of the block
return splitted.some((segment) => segment === blk.type); //FIXME (mcandeia) this is not a straightforward solution
return segments.some((segment) => segment === blk.type); //FIXME (mcandeia) this is not a straightforward solution
};

const asManifest = <TManifest extends AppManifest>(
Expand Down
4 changes: 2 additions & 2 deletions blocks/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const wrapCaughtErrors = async <
}

/**
* No special case found, throw and hope to be catch by the
* No special case found, throw and hope to be caught by the
* section's ErrorFallback
*/
throw err;
Expand Down Expand Up @@ -205,7 +205,7 @@ const wrapLoader = (
if (
bypassCache ||
// This code is unreachable, but the TS complains that cache is undefined because
// it doesn't get that isCache is inside of bypassCache variable
// it doesn't get that isCache is inside the bypassCache variable
!isCache(maybeCache)
) {
const shouldNotCache = isCacheNoStore || isCacheKeyNull;
Expand Down
2 changes: 1 addition & 1 deletion blocks/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const matcherBlock: Block<
let isSegment = true;

// from last to first and stop in the first resolvable
// the rational behind is: whenever you enter in a resolvable it means that it can be referenced by other resolvables and this value should not change.
// the rationale behind is: whenever you enter a resolvable it means that it can be referenced by other resolvables and this value should not change.
for (let i = httpCtx.resolveChain.length - 1; i >= 0; i--) {
const { type, value } = httpCtx.resolveChain[i];
if (type === "prop" || type === "resolvable") {
Expand Down
4 changes: 2 additions & 2 deletions clients/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class InvokeAwaiter<
}

then<TResult1, TResult2 = TResult1>(
onfufilled?: Fulfilled<
onfulfilled?: Fulfilled<
InvokeResult<
Invoke<TManifest, TInvocableKey, TFuncSelector>,
TManifest
Expand All @@ -59,7 +59,7 @@ export class InvokeAwaiter<
>,
onrejected?: Rejected<TResult2>,
): Promise<TResult1 | TResult2> {
return this.invoker(this.payload, this.init).then(onfufilled).catch(
return this.invoker(this.payload, this.init).then(onfulfilled).catch(
onrejected,
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function withSection<TProps, TLoaderProps = TProps>(
// if this is the case, so we can use the renderSaltFromState - which means that we are in a partial rendering phase
const renderSalt = parentRenderSalt === undefined
? renderSaltFromState ?? `${renderCount}`
: `${parentRenderSalt ?? ""}${renderCount}`; // the render salt is used to prevent duplicate ids in the same page, it starts with parent renderSalt and appends how many time this function is called.
: `${parentRenderSalt ?? ""}${renderCount}`; // the render salt is used to prevent duplicate ids in the same page, it starts with parent renderSalt and appends how many times this function is called.
const id = `${idPrefix}-${renderSalt}`; // all children of the same parent will have the same renderSalt, but different renderCount
renderCount = ++renderCount % MAX_RENDER_COUNT;

Expand Down
4 changes: 2 additions & 2 deletions daemon/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ const resolveConflictsRecursively = async (wip: number = 50) => {

/**
* Rebases with -XTheirs strategy. If conflicts are found, it will try to resolve them automatically.
* Conflicts happen when someone deletes a file and you modify it, or when you modify a file and someone else modifies it.
* Conflicts happen when someone deletes a file, and you modify it, or when you modify a file and someone else modifies it.
* In this case, the strategy is to keep the changes the current branch has.
*/
export const rebase: Handler = async () => {
Expand Down Expand Up @@ -364,7 +364,7 @@ export const ensureGit = async (
return;
}
const lockIndexPath = join(Deno.cwd(), ".git/index.lock");
// index.lock should not exists as it means that another git process is running or it is unterminated (non-atomic operations.)
// index.lock should not exist as it means that another git process is running, or it is unterminated (non-atomic operations.)
const hasGitIndexLock = await Deno.stat(lockIndexPath)
.then(() => true)
.catch((e) => e instanceof Deno.errors.NotFound ? false : true);
Expand Down
2 changes: 1 addition & 1 deletion engine/core/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const resolverIdFromResolveChain = (chain: FieldResolver[]) => {
let uniqueId = "";

// from last to first and stop in the first resolvable
// the rational behind is: whenever you enter in a resolvable it means that it can be referenced by other resolvables and this value should not change.
// the rationale behind is: whenever you enter a resolvable it means that it can be referenced by other resolvables and this value should not change.
for (let i = chain.length - 1; i >= 0; i--) {
const { type, value } = chain[i];
if (type === "prop" || type === "resolvable") {
Expand Down
2 changes: 1 addition & 1 deletion engine/core/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export const withResolveChainOfType = <
export const RESOLVE_SHORTCIRCUIT = "resolved";

/**
* wraps an arbitrary data as a resolved object skiping the config resolution algorithm.
* wraps an arbitrary data as a resolved object skipping the config resolution algorithm.
*/
export const asResolved = <T>(data: T, deferred?: boolean): T => {
return {
Expand Down
2 changes: 1 addition & 1 deletion engine/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const isPrimitive = <T>(v: T): boolean => {

export interface SingleFlight<T> {
/**
* Do separates executions between "keys"
* Do separate executions between "keys"
*/
do: (key: string, f: () => Promise<T>) => Promise<T>;
/**
Expand Down
2 changes: 1 addition & 1 deletion engine/decofile/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const compose = (...providers: DecofileProvider[]): DecofileProvider => {

const DECOFILE_RELEASE_ENV_VAR = "DECO_RELEASE";

// if decofile does not exists but blocks exists so it should be lazy
// if decofile does not exist but blocks exist so it should be lazy
const BLOCKS_FOLDER = join(Deno.cwd(), ".deco", "blocks");
const blocksFolderExistsPromise = exists(BLOCKS_FOLDER, {
isDirectory: true,
Expand Down
2 changes: 1 addition & 1 deletion engine/importmap/jsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const fetchMetaExports = (
`https://jsr.io/${packg}/${version}_meta.json`,
).then(
(meta) => meta.json() as Promise<PackageMeta>,
// there are other fields that dosn't need to be cached as they are very large.
// there are other fields that doesn't need to be cached as they are very large.
).then(({ exports }) => {
return { exports };
});
Expand Down
2 changes: 1 addition & 1 deletion engine/manifest/manifestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface ManifestBuilder<TManifest extends AppManifest = AppManifest> {
build(): string;
}
// function type any of root if not output
// if output gen output and add anyOf function type
// if output, gen output and add anyOf function type
export interface ExportDefault {
variable: Variable;
}
Expand Down
4 changes: 2 additions & 2 deletions engine/schema/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const withNotResolveType = (
/**
* Used as a schema for the return value of the given function.
* E.g, let's say you have a function that returns a boolean, and this function is referenced by `deco-sites/std/myBooleanFunction.ts`
* Say this function receives a input named `BooleanFunctionProps` that takes any arbitrary data.
* Say this function receives an input named `BooleanFunctionProps` that takes any arbitrary data.
* This function takes the mentioned parameters (functionRef and inputSchema) and builds a JSONSchema that uses the input as `allOf` property ("extends")
* and a required property `__resolveType` pointing to the mentioned function.
*
Expand Down Expand Up @@ -130,7 +130,7 @@ export interface SchemaBuilder {
build(): Schemas;
/**
* Add a new block schema to the schema.
* @param blockSchema is the refernece to the configuration input and the blockfunction output
* @param blockSchema is the reference to the configuration input and the blockfunction output
*/
withBlockSchema(blockSchema: BlockModule | EntrypointModule): SchemaBuilder;
}
Expand Down
2 changes: 1 addition & 1 deletion engine/schema/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const isSpannableArray = (child: any): child is Spannable[] => {
* As comments are treat as a separate array of strings containing only the information of which character it starts and ends (spannable).
* This code distribute it based on the span attribute of the comments, matching with the body span attribute.
*
* So it basically starts with all comments of the module, and then distribute it into body items, it recursively do the same thing inside a body item declaration if it is a TsInterface declaration,
* So it basically starts with all comments of the module, and then distribute it into body items, it recursively does the same thing inside a body item declaration if it is a TsInterface declaration,
* so that we have the comments assigned to the properties as well.
*/
const assignCommentsForSpannable = (_rootSpan: any) => {
Expand Down
6 changes: 3 additions & 3 deletions engine/schema/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const indexedBlocks = (
/**
* This function basically incorporate saved blocks in the schema so the user can select it through the UI as part of the schema.
* So it is divided in two phases
* 1. The first phase is responsible for incorporating on the root block types its saved definitions. For instance, handlers, sections and pages has no differentiation between its returns. So I don't need to group it individually they can be group alltogether
* 2. The second phase is for loaders that needs to be referenced based on its return type. So instead of putting in the loaders root type it should be put on its return type definition, e.g whereas a Product[] fit, a saved loader that returns a Product[] also fit.
* 1. The first phase is responsible for incorporating on the root block types its saved definitions. For instance, handlers, sections and pages has no differentiation between its returns. So I don't need to group it individually they can be grouped altogether
* 2. The second phase is for loaders that needs to be referenced based on its return type. So instead of putting in the loaders root type it should be put on its return type definition, e.g. whereas a Product[] fit, a saved loader that returns a Product[] also fit.
*/
const incorporateSavedBlocksIntoSchema = <
TAppManifest extends AppManifest = AppManifest,
Expand Down Expand Up @@ -92,7 +92,7 @@ const incorporateSavedBlocksIntoSchema = <
const first = anyOf && (anyOf[0] as JSONSchema7).$ref;
if (first === "#/definitions/Resolvable") { // means that this block can be swapped out to a saved block
anyOf?.splice(0, 1); // remove resolvable
definitions[ref] = { ...val, anyOf: [...val?.anyOf ?? []] }; // create a any of value instead of the value itself
definitions[ref] = { ...val, anyOf: [...val?.anyOf ?? []] }; // create an any of value instead of the value itself
const availableFunctions = (anyOf?.map((func) =>
getResolveType(func)
) ?? []).filter(notUndefined).reduce((acc, f) => {
Expand Down
4 changes: 2 additions & 2 deletions engine/schema/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ const wellKnownTypeReferenceToSchemeable = async <
if (literal.type !== "StringLiteral") {
return undefined;
}
const splitted = literal.value.split("/");
const split = literal.value.split("/");
return {
file: ctx.path,
type: "inline",
name: splitted[splitted.length - 1],
name: split[split.length - 1],
value: {
$ref: literal.value,
},
Expand Down
2 changes: 1 addition & 1 deletion engine/schema/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Some attriibutes are not string in JSON Schema. Because of that, we need to parse some to boolean or number.
* Some attributes are not string in JSON Schema. Because of that, we need to parse some to boolean or number.
* For instance, maxLength and maxItems have to be parsed to number. readOnly should be a boolean etc
*/
export const parseJSDocAttribute = (key: string, value: string) => {
Expand Down
4 changes: 2 additions & 2 deletions observability/otel/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const trackCfHeaders = [

registerInstrumentations({
instrumentations: [
// @ts-ignore: no idea why this is failing but it should work
// @ts-ignore: no idea why this is failing, but it should work
new FetchInstrumentation(
{
applyCustomAttributesOnSpan: (
Expand Down Expand Up @@ -134,7 +134,7 @@ const provider = new NodeTracerProvider({

if (OTEL_IS_ENABLED) {
const traceExporter = new OTLPTraceExporter();
// @ts-ignore: no idea why this is failing but it should work
// @ts-ignore: no idea why this is failing, but it should work
provider.addSpanProcessor(new BatchSpanProcessor(traceExporter));

provider.register();
Expand Down
2 changes: 1 addition & 1 deletion observability/otel/instrumentation/deno-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Heavily inspired from unlicense code: https://github.com/cloudydeno/deno-observability/blob/main/instrumentation/deno-runtime.ts
* Heavily inspired from unlicensed code: https://github.com/cloudydeno/deno-observability/blob/main/instrumentation/deno-runtime.ts
*/
import {
type Attributes,
Expand Down
2 changes: 1 addition & 1 deletion observability/otel/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class OpenTelemetryHandler extends log.BaseHandler {
: new OTLPLogExporter(options.httpExporterOptions);

const processor = new BatchLogRecordProcessor(
// @ts-ignore: no idea why this is failing but it should work
// @ts-ignore: no idea why this is failing, but it should work
exporter,
options.processorConfig,
);
Expand Down
4 changes: 2 additions & 2 deletions observability/otel/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const headersStringToObject = (headersString: string | undefined | null) => {
if (!headersString) {
return {};
}
const splittedByComma = headersString.split(",").map((keyVal) =>
const splitByComma = headersString.split(",").map((keyVal) =>
keyVal.split("=") as [string, string]
);
return Object.fromEntries(splittedByComma);
return Object.fromEntries(splitByComma);
};

// Add views with different boundaries for each unit.
Expand Down
2 changes: 1 addition & 1 deletion runtime/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Escape hatch to allow throwing an http error
* Escape hatch to allow throwing a http error
*/
export class HttpError extends Error {
public status: number;
Expand Down
4 changes: 2 additions & 2 deletions runtime/features/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const waitForChanges = async (ifNoneMatch: string, signal: AbortSignal) => {
if (etag !== ifNoneMatch) {
const info = await sf.do(context.instance.id, async () => {
const { manifest } = await context.runtime!;
const manfiestBlocks = toManifestBlocks(
const manifestBlocks = toManifestBlocks(
manifest,
);
const schema = await lazySchema.value;
Expand All @@ -79,7 +79,7 @@ const waitForChanges = async (ifNoneMatch: string, signal: AbortSignal) => {
version: denoJSON.version,
namespace: context.namespace!,
site: context.site!,
manifest: manfiestBlocks,
manifest: manifestBlocks,
schema,
platform: context.platform,
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const SERVER_TIMING_SEPARATOR: string = ",";
const SERVER_TIMING_MAX_LEN: number = 2_000;
/**
* @description return server-timing string equal or less than size parameter.
* if timings.length > size then return the timing until the well formed timing that's smaller than size.
* if timings.length > size then return the timing until the well-formed timing that's smaller than size.
*/
const reduceServerTimingsTo = (timings: string, size: number): string => {
if (timings.length <= size) return timings;
Expand Down
2 changes: 1 addition & 1 deletion types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export interface StatefulContext<T> {
export interface Route {
pathTemplate: string;
/**
* @description if true so the path will be checked agaisnt the coming from request instead of using urlpattern.
* @description if true so the path will be checked against the coming from request instead of using urlpattern.
*/
isHref?: boolean;
// FIXME this should be placed at nested level 3 of the object to avoid being resolved before the routeSelection is executed.
Expand Down
2 changes: 1 addition & 1 deletion utils/dataURI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Avoid throwing DOM Exception:
// The string to be encoded contains characters outside of the Latin1 range.
// The string to be encoded contains characters outside the Latin1 range.
const btoaSafe = (x: string) =>
btoa(`decodeURIComponent(escape(${unescape(encodeURIComponent(x))}))`);

Expand Down
2 changes: 1 addition & 1 deletion utils/patched_fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RequestContext } from "../deco.ts";

// Monkey patch fetch so we can have global cancelation token
// Monkey patch fetch so we can have global cancellation token
const fetcher = globalThis.fetch;

type RequestInitWithSignal = (RequestInit | globalThis.RequestInit) & {
Expand Down
2 changes: 1 addition & 1 deletion utils/promise.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Promise.prototype.then onfufilled callback type.
* Promise.prototype.then onfulfilled callback type.
*/
export type Fulfilled<R, T> = ((result: R) => T | PromiseLike<T>) | null;

Expand Down

0 comments on commit a2eb8c1

Please sign in to comment.