-
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.
Merge branch 'main' into sg/open-codegen
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 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
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,36 @@ | ||
// Rusha gives us a SHA1 (good enough for file content hashing) and was already | ||
// present in the Netlify React UI JS bundle when we introduced lockfiles | ||
import { createHash } from "rusha"; | ||
|
||
//TODO add schema content hash too? | ||
export type V0_format = { | ||
version: "v0"; | ||
locked: { | ||
schemaId: string; | ||
operationsHash: string; | ||
}; | ||
}; | ||
|
||
export const defaultLockFileName = "netlifyGraph.lock"; | ||
|
||
export const hashOperations = (operationsDoc: string) => { | ||
return createHash().update(operationsDoc).digest("hex"); | ||
}; | ||
|
||
export const createLockfile = ({ | ||
schemaId, | ||
operationsFileContents, | ||
}: { | ||
version?: string; | ||
schemaId: string; | ||
operationsFileContents: string; | ||
}): V0_format => { | ||
const operationsHash = hashOperations(operationsFileContents); | ||
return { | ||
version: "v0", | ||
locked: { | ||
schemaId, | ||
operationsHash, | ||
}, | ||
}; | ||
}; |
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